Undefined Method 'Has_Attached_File' with Paperclip 2.3.8 Gem for Rails 2 Using Ruby 1.8.7

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.

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

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"

Undefined method has_attached_file for my ActiveRecord model

I am not sure what happened. I ended up doing a db roll back and re-migrated the migration yet again. Then I exited all my terminals running in the background and restarted everything. It is working as of now.

Paperclip/docsplit has_attached_file not reconized

You made ​​a mistake. Read the documentation carefully.
You can move your code from controller to model(!).

Paperclip has_attached_file not working with Rails establish_connection

You need to install paperclip gem in the existing project, copy and configure AWS S3 information from the project which you need to access.

In Gemfile

# paperclip gem for image manipulation
gem 'paperclip', :git=> 'https://github.com/thoughtbot/paperclip', :ref => '523bd46c768226893f23889079a7aa9c73b57d68'

# aws sdk for uploading at AWS
gem 'aws-sdk', '< 2.0'
gem 's3'

In production.rb

# configuration for amazon s3
config.paperclip_defaults = {
:storage => :s3,
:s3_region=> ENV['AWS_REGION'],
:s3_credentials => {
:bucket => ENV['AWS_BUCKET'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}


Related Topics



Leave a reply



Submit