我试着在表单中设置单表继承模型类型。所以我有一个选择菜单的属性:类型和值是STI子类的名称。问题是错误日志保持印刷:Rails attr_accessible不适用于:type?
警告:不能批量分配这些保护属性:类型
,所以我说“attr_accessible:类型”的模式:
class ContentItem < ActiveRecord::Base
# needed so we can set/update :type in mass
attr_accessible :position, :description, :type, :url, :youtube_id, :start_time, :end_time
validates_presence_of :position
belongs_to :chapter
has_many :user_content_items
end
不改变任何东西,ContentItem仍然有:type = nil,在控制器中调用.update_attributes()之后。任何想法如何大规模更新表单中的:类型?
真棒!正是我需要的。 – jspooner 2011-03-04 19:53:31