我遇到过我的Rails 4应用程序的问题,我有一个使用masonry-rails gem的照片库。它基本上与约翰·埃尔德斯Pinterest克隆相同,但是有一张"照片"而不是"引脚"类。它通过Pundit与CRUD操作联系在一起。它完美地工作了几个月,直到最近才停止。我已卸载并重新安装,但在控制台中继续收到相同的错误消息:
Started GET "/photos" for 48.153.148.26 at 2017-02-14 17:01:17 +0000
Cannot render console from 48.153.148.26! Allowed networks: 128.0.0.1, ::1, 128.0.0.0/128.255.255.255
ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by PhotosController#index as HTML
DEPRECATION WARNING: [paperclip] [deprecation] AWS SDK v1 has been deprecated in paperclip 5. Please consider upgrading to AWS 2 before upgrading paperclip. (called from warn at /usr/local/rvm/gems/ruby-2.3.1@global/gems/paperclip-4.3.7/lib/paperclip/deprecations.rb:38)
W, [2017-02-14T17:01:18.195071 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.195490 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.203122 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.203470 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.208150 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.208470 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.216605 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.216975 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.221868 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.223774 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.228292 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.230086 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.235929 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.236274 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.241211 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.241558 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.250426 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.251149 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.256320 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-14T17:01:18.258134 #20170] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
Photo Load (0.3ms) SELECT "photos".* FROM "photos" ORDER BY created_at DESC LIMIT 20 OFFSET 0
Rendered photos/index.html.erb within layouts/application (20.3ms)
Rendered layouts/_shim.html.erb (0.4ms)
Rendered application/_favicon.html.erb (19.6ms)
Rendered layouts/_date.html.erb (0.3ms)
Rendered layouts/_date.html.erb (0.0ms)
Rendered layouts/_navigation.html.erb (9.1ms)
Rendered layouts/_footer.html.erb (2.8ms)
Completed 200 OK in 2382ms (Views: 1931.6ms | ActiveRecord: 0.7ms)
我搜索过并搜索过但无法找到任何类似的代码错误。我认为这可能是由另一个宝石造成的,因为它运行正常,直到我运行捆绑更新。另外,我有一个所见即所得的宝石,用于在捆绑更新后停止工作的样式帖子。我已经用Bootsy WYSWIG取而代之,而且这种宝石效果很好,但是Masonry-Rails仍然没有。
这是我的代码:
宝石文件
source 'https://rubygems.org'
ruby '2.3.1'
gem 'rails', '4.2.5'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.6'
gem 'active_link_to', '~> 1.0', '>= 1.0.3'
gem 'ionicons-rails', '~> 2.0'
gem 'devise', '~> 4.1', '>= 4.1.1'
gem 'paperclip', '~> 4.3', '>= 4.3.6'
gem 'aws-sdk', '< 2.0'
gem 'jquery-turbolinks'
gem 'masonry-rails', '~> 0.2.4'
gem 'will_paginate', '~> 3.1'
gem 'will_paginate-bootstrap', '~> 1.0', '>= 1.0.1'
gem 'mail_form', '~> 1.5', '>= 1.5.1'
gem 'simple_form', '~> 3.2', '>= 3.2.1'
gem 'bootsy', '~> 2.3', '>= 2.3.1'
gem 'rails_real_favicon', '~> 0.0.3'
gem 'instagram', '~> 1.1', '>= 1.1.6'
gem 'friendly_id', '~> 5.1'
gem 'faker', '~> 1.6', '>= 1.6.6'
gem 'pundit', '~> 1.1'
gem 'papercrop', '~> 0.3.0'
gem 'dotenv-rails', :require => 'dotenv/rails-now'
gem "recaptcha", require: "recaptcha/rails"
gem 'jquery-smooth-scroll-rails'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'sqlite3', '~> 1.3', '>= 1.3.11'
gem 'rspec-rails', '~> 3.5', '>= 3.5.2'
gem 'capybara', '~> 2.10', '>= 2.10.1'
gem 'factory_girl_rails', '~> 4.7'
gem 'database_cleaner', '~> 1.5', '>= 1.5.3'
gem 'shoulda-matchers', '~> 3.1', '>= 3.1.1'
end
group :test do
gem 'pundit-matchers', '~> 1.1.0'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
group :production do
gem 'pg', '~> 0.18.4'
gem 'rails_12factor', '~> 0.0.3'
end
的application.js
//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require jquery.jcrop
//= require papercrop
//= require turbolinks
//= require bootstrap-sprockets
//= require jquery-smooth-scroll
//= require bootsy
//= require customjs
//= require masonry/jquery.masonry
//= require_tree .
Application.css
*
*= require bootsy
*= require 'masonry/transitions'
*= require jquery.jcrop
*= require_tree .
*= require_self
*/
自定义JS文件
/*-------------------------------------------*/
/* MASONRY RAILS */
/*-------------------------------------------*/
$(document).ready(function(){
$(function() {
return $('#photos').imagesLoaded(function() {
return $('#photos').masonry({
itemSelector: ".box",
isFitWidth: true
});
});
});
});
照片页面index.html.erb
<% provide(:title, "Gallery") %>
<div class="container sports">
<div class="row">
<div class="col-md-9">
<div id="photos masonry-container" class="transitions-enabled">
<% @photos.each do |photo| %>
<div class="box">
<div class="panel">
<%= link_to image_tag(photo.image.url(:medium)), photo %><br>
<% if current_user&.admin? || current_user&.editor? %>
<div class="panel-body">
<%= photo.description %>
</div>
<div class="panel-footer center">
<p>Posted by: <%= photo.user&.username %><br>
<% if policy(photo).update? %>
<%= link_to 'Edit', edit_photo_path(photo) %> |
<% end %>
<% if policy(photo).destroy? %>
<%= link_to 'Delete', photo, method: :delete, data: { confirm: 'Are you sure?' } %>
<% end %>
</div>
<% end %>
</div>
</div>
<% end %>
</div>
<div class="center">
<%= will_paginate @photos, renderer: BootstrapPagination::Rails %>
</div>
</div>
</div>
</div>
画廊的其他所有内容都非常完美,包括Paperclip和Pundit。似乎是一个javascript错误或一个冲突的更新宝石,但我不知道Hashies。非常感谢任何帮助!
- UPDATE-- 要弄清楚我的确切问题是什么:当我查看照片索引页面时,我的照片是垂直堆叠而不是水平堆叠,因为带有转换脚本的Masonry gem应该这样做。它曾经是完美的,但在捆绑更新后,照片不再水平排列。