NoMethodError:未定义的方法`has_attached_file’
在检查插件的rails3分支后,Paperclip会产生此错误。 我的Gemfile有以下行:
gem 'paperclip', :git => 'http://github.com/thoughtbot/paperclip.git', :branch => 'rails3'
并且错误消息是:
NoMethodError: undefined method `has_attached_file' for #
更新06-21-10: 思想机器人版本已修复。
我必须在class Application < Rails::Application
的末尾将Paperclip::Railtie.insert
添加到我的application.rb中,以使其正常工作。 自官方回购工作以来,我已经删除了我的前叉。 希望能帮助别人。
您还需要将以下内容添加到Gemfile中
gem "paperclip", :git => "http://github.com/thoughtbot/paperclip.git"
我有一个回形针叉,你可以试试它是否会在你的最后工作,只需更改你的Gemfile:
gem 'paperclip', :git => 'git://github.com/lmumar/paperclip.git', :branch => 'rails3'
不要忘记在更新Gemfile后运行bundle install。
希望它能解决你的问题。
lmumar
minter’s fork为我工作:
gem 'paperclip', :git => 'http://github.com/minter/paperclip.git', :branch => 'rails3'
这对我不起作用。 我做了下面的事情,它完美地工作:
- 在application.rb中添加“Paperclip :: Railtie.insert”
- 在development.rb中添加“config.gem’paperclip’”
它适用于Jason King的回形针版本:
gem 'paperclip', :git => 'http://github.com/JasonKing/paperclip.git', :branch => 'rails3'