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