【发布时间】:2015-05-11 18:48:01
【问题描述】:
我为我的第一个模型安装了 Paperclip,它工作正常,但是当我尝试将它添加到我的第二个模型时出现错误。我基本上是想为我创建的两个模型上传两个图像。这是错误:
undefined method `image_content_type' for #<IosCourse:0x007fd4bb3bfaf0>
这是我的第一个模型(Rubycourse.rb):
class Rubycourse < ActiveRecord::Base
acts_as_votable
has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
has_many :reviews
end
这是第二个模型(IosCourse.rb):
class IosCourse < ActiveRecord::Base
attr_accessor :image_file_name
has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
end
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-4 ruby-on-rails-3.2 paperclip