Undefined method `has_attached_file' with paperclip 2.3.8 gem for Rails 2 using Ruby 1.8.7

后端 未结 2 1014
青春惊慌失措
青春惊慌失措 2021-01-20 07:37

I am trying to use the paperclip plugin in my rails app to upload images for posts. I am using Rails 2.0.2 and ruby 1.8.7 on Ubuntu 10.04 os for project specific purposes.

2条回答
  •  旧巷少年郎
    2021-01-20 07:59

    Slightly related, decided to put this here for future googlers.

    Using Rails 2.3.14 on Ruby 1.8.7 with bundler. As suggested by thoughtbot I'm using paperclip 2.7, i.e. my gemfile contains:

    gem "paperclip", "~> 2.7.0"
    

    I was also receiving the "undefined method" error. What fixed it for me was to drop a paperclip.rbfile into config/initializerscontaining the following:

    require "paperclip/railtie"
    Paperclip::Railtie.insert
    

    Hopefully this will save someone a bit of headache.

提交回复
热议问题