Andrey Krisanov
2012-Aug-08 07:04 UTC
Devise with many models and ArgumentError in RegistrationController#create
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! -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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.
Yong Gu
2012-Aug-08 07:10 UTC
Re: Devise with many models and ArgumentError in RegistrationController#create
If there has_one :character in your model? On Aug 8, 2012, at 3:04 PM, Andrey Krisanov wrote:> 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! > > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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. > >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Andrey Krisanov
2012-Aug-08 07:33 UTC
Re: Devise with many models and ArgumentError in RegistrationController#create
Yes, see my models https://gist.github.com/3288141 среда, 8 августа 2012 г., 11:10:48 UTC+4 пользователь zerogy написал:> > If there has_one :character in your model? > > On Aug 8, 2012, at 3:04 PM, Andrey Krisanov wrote: > > 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! > > -- > 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...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<javascript:> > . > To unsubscribe from this group, send email to > rubyonrails-ta...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. > 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. > > > > >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/qq776fSt2pAJ. For more options, visit https://groups.google.com/groups/opt_out.
Yong Gu
2012-Aug-08 08:20 UTC
Re: Devise with many models and ArgumentError in RegistrationController#create
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 написал: > If there has_one :character in your model? > > On Aug 8, 2012, at 3:04 PM, Andrey Krisanov wrote: > >> 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! >> >> -- >> 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...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> 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. >> >> > > > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/qq776fSt2pAJ. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.