0

ローカルホストでは、Masonry が完全に機能しています。しかし、Heroku にプッシュした後、本番環境では機能しませんでした。私はすでにすべてのアセットをプリコンパイルしています。

assets/javascripts フォルダーに masonry.pkgd.min.js ファイルを保存しています

これが私の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>

私が言ったように、開発ではすべてがうまくいきますが、生産はまったく機能しません。

これは開発です: これは開発中のスクリーンショットです

これは生産です: ここに画像の説明を入力

4

1 に答える 1

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

それが役立つことを願っています!

于 2013-11-01T19:42:19.297 に答える