ruby on rails - Setting attribute of one model in the create view of another model -


I have a user model that has_one profile, and profile belongs to user. A table in the profile is a type column for succession that is called "artist" or "listener". I want the user to set it up to sign up for a new user view. So I have this code in the form:

  <% = f.fields_for: Profile do | T | & Gt%; & Lt; Div class = "field" & gt; & Lt;% = t.label: type, "Are you an artist or listener?" % & Gt; & Lt; Br / & gt; & Lt;% = t.radio_button: type "artist"%> & Lt;% = t.radio_button: type "listener"%> & Lt; / Div & gt; & Lt;% end% & gt;   

And it is in my user model:

  accepts_name_at for: profile   

but I The error is found:

  ArgumentError video showing in the #rubyprograms/dreamstill/app/views/videos/_video.html.erb where Row # 3 has been raised: Name 'Profile' No cooperation found for the name. Has it been defined so far?   

Why is it, and how can I fix it?

In addition, I am very confused why the error brings 3 lines in my video partial, which does not mention it profile at all ... < P> UPDATE:

This is the complete form:

  & lt;% = form_for (@user) what. F | & Gt%; & Lt;% If @ user.errors.any? & Gt%; & Lt; Div id = "errorExplanation" & gt; & Lt; H2 & gt; & Lt;% = Multifunctional (@UserRoaders quote, "Error")%> Restricted from saving this user: & lt; / H2 & gt; & Lt; Ul & gt; & Lt;% @ user.errors.full_messages.each do Msg | | & Gt%; & Lt; Li & gt; & Lt;% = msg% & gt; & Lt; / Li & gt; & Lt;% end% & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt;% end% & gt; & Lt; Div class = "field" & gt; & Lt;% = f.label: email% & gt; & Lt; Br / & gt; & Lt;% = f.text_field: email% & gt; & Lt; / Div & gt; & Lt; Div class = "field" & gt; & Lt;% = f.label: Password% & gt; & Lt; Br / & gt; & Lt;% = f.password_field: Password% & gt; & Lt; / Div & gt; & Lt; Div class = "field" & gt; & Lt;% = f.label: password_confirmation, "password confirmation"%> & Lt; Br / & gt; & Lt;% = f.password_field: password_confirmation% & gt; & Lt; / Div & gt; & Lt;% = f.fields_for: profiling | T | & Gt%; & Lt; Div class = "field" & gt; & Lt;% = t.label: type, "Are you an artist or listener?" % & Gt; & Lt; Br / & gt; & Lt;% = t.radio_button: type "artist"%> & Lt;% = t.radio_button: type "listener"%> & Lt; / Div & gt; & Lt;% end% & gt; & Lt; Div class = "field" & gt; & Lt;% = f.label: name, "full name"%> & Lt; Br / & gt; & Lt;% = f.text_field: name% & gt; & Lt; / Div & gt; & Lt; Div class = "action" & gt; & Lt;% = f.submit% & gt; & Lt; / Div & gt; & Lt;% end% & gt;   

And these user models have three rows relevant to profiles:

  accepts_ansted_at for: profile before_create: build_profile has_one: profile   

You should edit your model and set it all in the correct order:

  is_one: Profile # It should be approved before_Applied_Authority: Create profile first: build_profile    

Comments