Я пытаюсь:
@item.associations.update_attributes(:tag_id=>params[:tag])
и
@item.associations.tag_id=params[:tag]
Оба дают мне неопределенные ошибки метода для update_attributes и tag_id =, соответственно. Вот мои настройки:
class Item < ActiveRecord::Base
has_many :associations,:foreign_key=>"item_id",:dependent=>:destroy
has_many :reverse_associations,:foreign_key=>"tag_id",:class_name=>"Association"
has_many :tags,:through=>:associations
end
class Tag < ActiveRecord::Base
has_many :associations,:foreign_key=>"tag_id",:dependent=>:destroy
has_many :reverse_associations,:foreign_key=>"item_id",:class_name=>"Association"
has_many :items,:through=>:associations
attr_accessible :name
end
class Association < ActiveRecord::Base
belongs_to :item
belongs_to :tag
end
Что я делаю не так?