Why Do I Get an "Undefined Method for 'Has_Attached_File' When Installing Paperclip

Why do I get an undefined method for `has_attached_file` when installing PaperClip?

It is very important that you restart your server after installing new gems/plugins. This should solve your problem

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

Ok, firstly, just to cover the "obvious" base: do "ls vendor/plugins" just to make sure that some version of paperclip is actually in your plugins directory and is therefore reachable by your application.

Secondly - the "require paperclip" in the model seems wrong to me. I'm guessing that require should go in your environment instead. Try putting it at the end of config/environments.rb instead.

Thirdly (and maybe unrelated to your specific problem) - 2.0.2 is a really old version of rails. If you can I'd upgrade to 2.3.5, or at the very least, 2.2.x. For all we know - you could have a problem because you've got a new version of paperclip and an old version of rails... this does sometimes make a difference.

A lot of the other links you posted are referring to installations up to Rails3 - the solutions to their problems will be different to yours for that reason.

undefined method `has_attached_file' : Paperclip error with ActiveAdmin and cucumber

After checking all files and experiments, I finally found the solution. The problem was paperclip.rb file in Rails.root/lib folder. The file contains no content but it creates problem while I was running cucumber. So I deleted that file and all works. Let's hope this helps to other :-)

NoMethodError: undefined method `has_attached_file'

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"

Rails + Paperclip Error! undefined method `has_attached_file'

I solved delete the model and re create correctly...

rails g model user_icons user_id:integer url:string image:attachment

I need declare the param to file upload and used this in my paperclip model..

rookie mistake!! ;(



Related Topics



Leave a reply



Submit