我在Rails 3中有兩個模型 - 一個用戶模型和一個Profile模型。Rails scoped form not assigneding belongs_to
class User < ActiveRecord::Base
has_one :profile, :dependent => :destroy
end
class Profile < ActiveRecord::Base
belongs_to :user
end
他們在我的routes.rb文件範圍的,因爲這樣的:
resources :users do
resources :profiles
end
所以,現在,我的表單創建一個配置文件讀取這樣的(使用SimpleForm):
<%= simple_form_for([@user, @profile]) do |f| %>
<%= f.error_notification %>
...(Other Inputs)
<% end %>
但是,我認爲用戶標識似乎不會自動發送到配置文件模型。我必須通過控制器手動設置嗎?或者我錯過了什麼?
有記錄在配置文件數據庫字段'user_id'? – thoferon