I’ve installed paperclip to my project as plugin using
ruby script/plugin install http://github.com/thoughtbot/paperclip.git
Model:
class Company < ActiveRecord::Base
has_attached_file :logo, :styles => { :large => "300x300>", :medium => "100x100>", :thumb => "50x50>" }
validates_attachment_content_type :logo, :content_type => image/jpeg, :message => "Incorrect logo file type!"
validates_attachment_size :log, :max => 200, :message => "big file"
end
But controller methods returns:
NoMethodError in CompaniesController#new undefined method `has_attached_file’ for #
If i try to “require ‘paperclip’ ” before model class, returned:
MissingSourceFile in CompaniesController#new
no such file to load — paperclip
What is the problem?
Since you have installed paperclip as a plugin, verify that it has actually been placed at the correct path in your app. It seems unlikely that it wouldn’t be correct but I prefer to troubleshoot by checking what is working instead of what is not working 🙂
You should have a folder structure like this:
RAILS_ROOT/vendor/plugins/paperclip/lib/paperclip.rb
When it looks like this, rails should load paperclip.rb by default at every restart of the server. That is unless the app is configured NOT to load all plugins by default. Those configurations can be found in config/environment.rb
I would look for any entry like the following:
If you find any entry like those, that might be the cause of the problem.