嘗試執行一個嵌套對象窗體。該頁面加載沒有錯誤,但是當我發送它時,沒有信息被保存到組織模型中。另一個導軌嵌套窗體問題
SQL調用說這個..
Parameters: {"commit" => "save", "action"=>"update","_method"=>"put", "organization"=>{"likes_snacks"=>"0"}, ..
這是正確的。通過打開和關閉複選框可以正確更改1和0。但是,我猜這些信息並沒有保存到數據庫中。有任何想法嗎?
HAML:
- form_for @user do |f|
= f.label :username
= f.text_field :username
.clear
- fields_for :organization do |org| unless @user.organizations.empty?
= org.label :likes_snacks, 'Like snacks?'
= org.check_box :likes_snacks
= f.submit 'save', {class => 'button'}
CONTROLLER:
def edit
@user = current_user
@organization = current_user.organizations.first
end
模型:
ORGANIZATION.RB:
has_many :users, :through => :organizations_users
USER.RB:
has_many :organizations, :through => :organizations_users
如果你可以張貼'user'和'organization'型號代碼也更好。 – randika 2010-07-19 16:53:29
f.text_field:username是否保存到數據庫? – 2010-07-19 16:55:20
@jesse是的它確實 – Trip 2010-07-19 17:02:18