在本地主机上,我的 Masonry 工作得很好。但是,在我推到 Heroku 之后,它在生产中不起作用。我已经预编译了所有资产。
我将 masonry.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>
就像我说的,在开发中一切正常,但生产根本不起作用。
这是发展:
这是生产: