我有三個型號:這段代碼中的編輯和新操作是什麼?
class Country < ActiveRecord::Base
has_many :regions
has_many :assets, :dependent => :destroy
accepts_nested_attributes_for :assets
end
class Region < ActiveRecord::Base
belongs_to :country
has_many :appartments
has_many :assets, :dependent => :destroy
accepts_nested_attributes_for :assets
end
class Asset < ActiveRecord::Base
belongs_to :region
belongs_to :country
has_attached_file :image,
:styles => {
:thumb=> "100x100>",
:small => "300x300>",
:large => "600x600>"
}
end
可以給我一些解釋一下什麼是編輯和新方法/措施是區域控制器,存儲資產(圖片)?
如果你使用'accepts_nested_attributes_for:assets'您所在區域的模型裏面,比動作將與創建/編輯區域相同。所以實際的資產存儲將在區域保存時生成(在regions_controller#create&regions_controller#更新操作中) – Hck