Forum: Ruby on Rails Error in Polymorphic association with Devise gem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1f97bf4766a22c544e94678db01b343a?d=identicon&s=25 Joy Ganguly (Guest)
on 2014-04-21 16:30
(Received via mailing list)
I am creating a Polymorphic association with Devise Gem in Rails 4 but
when saving the form, the data of the User is not saving. In console it
is
showing "*Unpermitted parameters: user*".

The main idea  is that there are two types of users organizer and vendor
each has  different fields in registration form so i want each to have
respective  registration form but a single signin form.....code is
pasted
here https://gist.github.com/himadriganguly/11112184

Thanks to all in advance.
F50d3b02eee623a2172b58c09fe31c2c?d=identicon&s=25 mike2r (Guest)
on 2014-04-21 18:44
(Received via mailing list)
On Monday, April 21, 2014 10:25:01 AM UTC-4, Joy Ganguly wrote:
> Thanks to all in advance.
>

I'm pretty sure the error is in the register_params of the organiser
controller, but I don't know why it's happening.  it looks like you have
the correct formats.  When you have "f.fields_for :user" it will pass
the
parameters as [user][email], [user][first_name], etc.  It looks to me
like
it's seeing a parameter [user], it isn't permitted in the strong
parameters, and it's throwing an error.  However, you have
accepts_nested_attributes_for defined and usually when you use the hash
user_attributes in strong parameters, rails takes care of that.  You
might
try the following:

params.require(:organiser).permit(:city, :mobile, user: [:first_name,
:last_name, ... , :authenticable_type])

if that works, I'm not sure why it's necessary.  When I have time, I'll
try
to play with this.  The only difference between this and other instances
I've seen of this type of structure is that in this case, both the
parent
and the associated child record are new vs other situations where the
parent is already established and you're adding a new child record.
sorry
I haven't really given you a definitive answer here but hopefully it
will
give you some ideas on where to focus your efforts.
A47e0a6beeb9d048ff054fc1c3a97418?d=identicon&s=25 Walter Davis (walterdavis)
on 2014-04-21 20:07
(Received via mailing list)
Did you try permit(user_attributes: []) (setting it as an array)? That's
necessary for any non-scalar attribute in strong parameters.

Walter
This topic is locked and can not be replied to.