1
我有一個多標籤模式的選擇標籤,並希望我的控制器更新操作將多個條目保存到has_many_and_belongs_to_many關聯表中。我的控制器應該如何更新動作,我想我必須循環傳入參數?Rails:將多選標籤保存爲has_many_and_belongs_to_many關聯
電流控制器代碼:
def update
if @user.update_attributes(params[:user])
flash[:success] = 'Your profile has been updated'
end
end
走路軌!謝謝。最後使用這一行:= f.collection_select:association_ids,Association.all,:id,:name,{:selected => @ user.association_ids},{multiple:true} – christian