所以基本上我已经编写了自己的身份验证而不是使用 gem,所以我可以访问控制器。我的用户创建工作正常,但是当我的用户被创建时,我还想在我的个人资料模型中为他们创建个人资料记录。我已经让它大部分工作了我似乎无法将新用户的 ID 传递到新的 profile.user_id 中。这是我在我的用户模型中创建用户的代码。
def create
@user = User.new(user_params)
if @user.save
@profile = Profile.create
profile.user_id = @user.id
redirect_to root_url, :notice => "You have succesfully signed up!"
else
render "new"
end
配置文件正在创建它只是没有从新创建的用户添加 user_id。如果有人可以提供帮助,将不胜感激。