Reputation: 17834
I have a user model and a profile model. In user.rb
has_one :profile
and in profile model
belongs_to :user
and when now I'm trying to create a profile for the current user in profiles#create
@profile = current_user.profile.new(params[:profile])
it throws an unknown method 'new' error. How to fix this problem? Please help?
Upvotes: 0
Views: 31
Reputation: 12320
@profile = current_user.build_profile(params[:profile])
@profile.save!
Upvotes: 1