我在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