我在运行时遇到涉及PaperClip的错误。我按照Paperclip github页面的说明进行操作。涉及回形针的细节如下所述。有什么我可能错过的吗?
错误记录
/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/activerecord-4.1.6/lib/active_record/dynamic_matchers.rb:26:in 'method_missing': undefined method 'has_attatched_file' for Vehicle (call 'Vehicle.connection' to establish a connection):Class (NoMethodError)
环境
vehicle.rb
class Vehicle < ActiveRecord::Base
has_attatched_file :main_photo, :styles => { :medium => "300x300>", "thumb" => "100x100>" }, :default_url => "/images/:style/missing.png"
validates_attatchment_content_type :main_photo, :content_type => /\Aimage\/.*\Z/
end
的Gemfile
gem "paperclip", "~> 4.3"
答案 0 :(得分:1)
你有一个错字的老兄。您需要has_attached_file
而不是has_attatched_file
。
class Vehicle < ActiveRecord::Base
has_attached_file :main_photo, :styles => { :medium => "300x300>", "thumb" => "100x100>" }, :default_url => "/images/:style/missing.png"
validates_attatchment_content_type :main_photo, :content_type => /\Aimage\/.*\Z/
end