NoMethodError: undefined method `has_attached_file'

混江龙づ霸主 提交于 2019-12-10 03:41:48

问题


Paperclip produces this error, after checking out the plugin's rails3 branch. My Gemfile has following line:

gem 'paperclip', :git => 'http://github.com/thoughtbot/paperclip.git', :branch => 'rails3'

And the error message is:

NoMethodError: undefined method `has_attached_file' for #<Class:0x2a50530>

回答1:


Update 06-21-10: the thoughtbot version has been fixed.

I had to add Paperclip::Railtie.insert to my application.rb at the end of class Application < Rails::Application to get it to work correctly. I have deleted my fork since the official repo is working. Hope that helps someone.

You will also need to add the following to your Gemfile

gem "paperclip", :git => "http://github.com/thoughtbot/paperclip.git"



回答2:


I have a paperclip fork, you can try if it will work at your end, just change your Gemfile:

gem 'paperclip', :git => 'git://github.com/lmumar/paperclip.git', :branch => 'rails3'

Don't forget to run bundle install after updating your Gemfile.

Hope it will fix your problems.

lmumar




回答3:


minter's fork worked for me:

gem 'paperclip', :git => 'http://github.com/minter/paperclip.git', :branch => 'rails3'



回答4:


That didn't work for me. I have done below things and it is working perfectly:

  • Add "Paperclip::Railtie.insert" in application.rb
  • Add "config.gem 'paperclip'" in development.rb



回答5:


it works with Jason King's paperclip version:

gem 'paperclip', :git => 'http://github.com/JasonKing/paperclip.git', :branch => 'rails3'


来源:https://stackoverflow.com/questions/2743902/nomethoderror-undefined-method-has-attached-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!