単一テーブルの継承モデル タイプをフォームに設定しようとしています。したがって、属性 :type の選択メニューがあり、値は STI サブクラスの名前です。問題は、エラー ログが出力され続けることです。
警告: これらの保護された属性をまとめて割り当てることはできません: type
だから私は "attr_accessible :type" をモデルに追加しました:
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
コントローラーで .update_attributes() が呼び出された後も、ContentItem には :type=nil が残っています。フォームから :type を一括更新する方法はありますか?