0
我有一个“兴趣”列表,表示我的系统中的每个用户都有能力评分。管理员可以随时添加/删除兴趣。当用户去编辑他们的帐户时,我想要显示系统中所有兴趣的列表,并以1..5的值显示下拉列表。我想知道如何设置它..导轨中的静态嵌套元素
使用accep_nested_attributes似乎并没有工作,因为当我使用field_for它想要为每个已保存的兴趣创建表单。我想要的是每个兴趣都显示出来,如果用户之前对兴趣进行了评级,则会更新该值,如果尚未评估过,则添加一个新条目。
目前用户:
has_many :user_interests, :dependent => :destroy
has_many :interests, :through => :user_interests, :foreign_key => :user_id
accepts_nested_attributes_for :user_interests
目前一个使用者兴趣:
belongs_to :user
belongs_to :interest
目前的兴趣:
has_many :user_interests, :dependent => :destroy
has_many :users, :through => :user_interests, :foreign_key => :interest_id, :dependent => :destroy