Paperclip Gem - 未定义的方法'_image_post_process_callbacks'

时间:2016-03-17 19:43:31

标签: ruby-on-rails ruby ruby-on-rails-4 paperclip

我在Heroku上有一个使用Paperclip宝石的应用程序,它最近有一些问题 - 我并不是100%确定是什么导致了它。我让应用程序在本地工作(包括图像上传) - 但我在heroku url上得到一个'Application Error'页面,当我尝试使用heroku运行rails c访问heroku控制台时,它会出现以下错误:

/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/dynamic_matchers.rb:26:in 'method_missing': undefined method '_image_post_process_callbacks' for #<Class:0x007f8aaf5d2fa0> (NoMethodError)

关于这个问题的一点背景 - 另一位开发人员正致力于创建一个名为'Images'的图像上传模型 - 我认为这会导致Paperclip出现问题,并且不允许我运行Rails迁移。当我尝试它说'图像'表有问题,所以在网上找到类似的情况之后,我在create_images迁移中注释掉了'def change'的主体 - 现在看起来像这样:

class CreateImages < ActiveRecord::Migration
def change
# create_table :images do |t|
# t.attachment :file
# end
end
end

然后我又进行了另一次迁移 - 在本地启动了我的服务器,一切正常。然后我将我的更改推送到heroku,做了一个rake db:为了好运而迁移 - 并且heroku url仍显示'Application Error'

如果有人知道这些问题的可能原因,我们将不胜感激!谢谢你的阅读!

修改

运行heroku run rails c后,我得到了这个输出。

Running rails c on independentskiermag... up, run.7049 Routing about Routing terms-of-service Routing privacy-policy Routing contact /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/dynamic_matchers.rb:26:in 'method_missing': undefined method '_image_post_process_callbacks' for #<Class:0x007f9ff5864330> (NoMethodError) from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:785:in 'get_callbacks' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:647:in 'set_callback' from (eval):2:in 'before_image_post_process' from /app/vendor/bundle/ruby/2.0.0/gems/paperclip-4.3.2/lib/paperclip/validators.rb:67:in 'create_validating_before_filter' from /app/vendor/bundle/ruby/2.0.0/gems/paperclip-4.3.2/lib/paperclip/validators.rb:60:in 'block in validate_before_processing' from /app/vendor/bundle/ruby/2.0.0/gems/paperclip-4.3.2/lib/paperclip/validators.rb:58:in 'each' from /app/vendor/bundle/ruby/2.0.0/gems/paperclip-4.3.2/lib/paperclip/validators.rb:58:in 'validate_before_processing' from /app/vendor/bundle/ruby/2.0.0/gems/paperclip-4.3.2/lib/paperclip/validators/attachment_content_type_validator.rb:84:in 'validates_attachment_content_type' from /app/app/models/image.rb:4:in '<class:Image>' from /app/app/models/image.rb:1:in '<top (required)>' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in 'require' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in 'block in require' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in 'load_dependency' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in 'require' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:360:in 'require_or_load' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:317:in 'depend_on' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:233:in 'require_dependency' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:472:in 'block (2 levels) in eager_load!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:471:in 'each' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:471:in 'block in eager_load!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:469:in 'each' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:469:in 'eager_load!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:346:in 'eager_load!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/application/finisher.rb:56:in 'each' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/application/finisher.rb:56:in 'block in <module:Finisher>' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/initializable.rb:30:in 'instance_exec' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/initializable.rb:30:in 'run' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/initializable.rb:55:in 'block in run_initializers' from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:150:in 'block in tsort_each' from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:183:in 'block (2 levels) in each_strongly_connected_component' from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:219:in 'each_strongly_connected_component_from' from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:182:in 'block in each_strongly_connected_component' from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in 'each' from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in 'each_strongly_connected_component' from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:148:in 'tsort_each' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/initializable.rb:54:in 'run_initializers' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/application.rb:352:in 'initialize!' from /app/config/environment.rb:5:in '<top (required)>' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in 'require' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in 'block in require' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in 'load_dependency' from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in 'require' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/application.rb:328:in 'require_environment!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:142:in 'require_application_and_environment!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:67:in 'console' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in 'run_command!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in '<top (required)>' from /app/bin/rails:8:in 'require' from /app/bin/rails:8:in '<main>'

1 个答案:

答案 0 :(得分:0)

首先,如果您需要在Heroku上撤消迁移,则需要取消注释迁移的正文,推送到Heroku,然后运行heroku run rake db:rollback以撤消它并获取您的应用程序在过渡期间再次工作。

如果您仍然遇到问题,请在帖子中发布错误和相关代码。