Devise with many models and ArgumentError in RegistrationController#create

25 views
Skip to first unread message

Andrey Krisanov

unread,
Aug 8, 2012, 3:04:32 AM8/8/12
to rubyonra...@googlegroups.com
Hello! I write custom registration for different user types.

I have Devise model User and two models (roles) Company and Invidual: https://gist.github.com/3288141
I created UserObserver https://gist.github.com/3288157
Registration view: https://gist.github.com/3288189 and partial (by default for Company) https://gist.github.com/3288198

In addition to the fields of User on the form displays the Name field of Company model.
But when I press the submit button, I get an error "ArgumentError in RegistrationController#create"
Cannot build association character. Are you trying to build a polymorphic one-to-one association?

Application Trace | Framework Trace | Full Trace 
app/controllers/registration_controller.rb:14:in `create'
Request
Parameters: 
{"utf8"=>"✓",
 "authenticity_token"=>"62bE9GNDQ1QFn5UDP34EmxLlHSRiKzCSPwJO8BiNuYU=",
 "user"=>{"character_type"=>"Company",
 "email"=>"",
 "password"=>"[FILTERED]",
 "password_confirmation"=>"[FILTERED]",
 "character_attributes"=>{"name"=>""}},
 "commit"=>"Зарегистрироваться"}

How fix it? Thanks for your answers! 

Yong Gu

unread,
Aug 8, 2012, 3:10:48 AM8/8/12
to rubyonra...@googlegroups.com
If there has_one :character in your model?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/v0kbEPY_nn8J.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Message has been deleted

Yong Gu

unread,
Aug 8, 2012, 4:20:42 AM8/8/12
to rubyonra...@googlegroups.com
Maybe this can help you: http://stackoverflow.com/questions/3969025/accepts-nested-attributes-for-with-belongs-to-polymorphic

On Aug 8, 2012, at 3:33 PM, Andrey Krisanov wrote:

Yes, see my models https://gist.github.com/3288141

среда, 8 августа 2012 г., 11:10:48 UTC+4 пользователь zerogy написал:
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/qq776fSt2pAJ.
Reply all
Reply to author
Forward
0 new messages