Ruby on Rails Monday, December 30, 2013

Colin Law wrote in post #1131851:
> On 30 December 2013 12:36, Ravi Vendan <lists@ruby-forum.com> wrote:
>>>>
>> I had tried. This works, but while saving user_profile field values are
>> nil except ids.
>> my create method like this
>>
>> @user = User.new(user_params)
>> @user_profile = @user.build_user_profile(params[:user_profile])
>
> Have a look in log/development.log and you will see the parameters you
> are posting and check they are ok. Also you can do thinks like
> inserting puts statements into your code, so if you insert
>
> puts inspect params[:user_profile]
>
> in the code above it will print the params in the server terminal
> window so you can check they are ok.
>
> Colin

I found the reason but I can not solve it.
user_profile is unpermitted parameter.

I added

def user_params
params.require(:user).permit(:email, :password,
:user_profile_attributes =>[])
end
in the conroller and

accepts_nested_attributes_for :user_profile

in the model.

still the same problem.

Thanks

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ff76b2ec4725a91706c01b5e05b90ea0%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment