砌体jquery无法在生产中渲染(Heroku)

时间:2013-11-01 02:09:59

标签: javascript jquery ruby-on-rails ruby heroku

在localhost上,我有完美的砌体工作。然而,在我推到Heroku后,它并没有在生产中工作。我已经预编译了所有资产。

我的masanry.pkgd.min.js文件存储在我的assets / javascripts文件夹中

这是我的applicaiton.html.erb:

<!DOCTYPE html>
<html>
<head>
  <title><%= content_for?(:title) ? yield(:title) + ' @ SeekAfter' : "SeekAfter" %></title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <%= stylesheet_link_tag    "application", :media => "all" %>
  <%= javascript_include_tag "application" %>
  <%= csrf_meta_tags %>
</head>
<body>

<%= render 'layouts/navigation' %>

<div class = 'container'>
  <%= render 'layouts/messages' %>
  <%= yield %>
</div>
<p style='text-align:center'><em>A place to have conversations</em> | <%= link_to "Contact us", contact_path %></p>
</body>
</html>

这是我的索引视图:

<div id="masonry-container" class="js-masonry transitions-enabled infinite-scroll clearfix"
  data-masonry-options='{ "itemSelector": ".thumbnail", "gutter": 5}'>
    <% @conversations.each do |conversation| %>
        <!-- <div class="col-sm-6 col-md-4"> -->
          <div class="thumbnail">
                <h3><%= link_to conversation.title, conversation %></h2>
                <p>Comments: <span class='badge'><%= conversation.comments.count %></span></p>
                <p><%= simple_format(hashtag_link(conversation.description)) %></p>
                <p><b>Submitted by:</b> <%= link_to conversation.user.username, user_path(conversation.user.id) %></p>
                <h3> Recent comments: </h3>
                <hr>
                <% conversation.comments.sort_by{|t| - t.created_at.to_i}.take(3).each do |c| %>
                    <div class='media'>
                        <%= image_tag c.user.profile_pic.url(:thumb), class: 'media-object pull-left img-polaroid' %>
                      <div class='media-body'>
                        <h4 class='media-heading'><%= link_to c.user.username, user_path(c.user.id) %><small> @ <%=c.created_at.strftime("%m/%d/%Y at %I:%M%p") %></small></h4>
                        <%= simple_format(hashtag_link(c.message)) %>
                      </div>
                    </div>
                    <hr>
                  <% end %>
                <%= editing_for_current_user(conversation) %>
          </div>
        <!-- </div> -->
    <% end %>
</div>

正如我所说,一切都在开发中运作良好,但生产根本不起作用。

这是发展: This is a screenshot of development

这是生产: enter image description here

1 个答案:

答案 0 :(得分:0)

我实际上已经明白了。

使用此:

masonry.pkgd.js

而不是:

masonry.pkgd.min.js

该文件应放在assets / javascripts文件夹中。您的application.js文件也应如下所示:

    // This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require masonry.pkgd.js
//= require bootstrap
//= require_tree

希望有所帮助!