当对 /cloth/create 进行 POST 时,我收到警告:无法批量分配受保护的属性:标题、描述、布料类型、图片
布料.rb
class Cloth
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes attr_accessible :pics
field :title
field :description
field :cloth_type
belongs_to :seller
has_many :pics
attr_accessible :pic_attributes
accepts_nested_attributes_for:pics
end
图片.rb
class Pic
include Mongoid::Document
include Mongoid::Paperclip
has_mongoid_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" },
:storage => :cloud_files,
:cloudfiles_credentials => "#{Rails.root}/config/rackspace.yml",
:path => ":attachment/:id/:timestamp_:style.:extension"
belongs_to :cloth
attr_accessible :cloth_attributes
def create
@cloth = Cloth.create!(params[:cloth])
end
end