ruby on rails - Can't get my type attribute set in my Profile model for STI -


I have a user model that is is_one: profile And in the profile model there is a type column for inheriting a table. I want to set up a type to sign up a user, and I'm having trouble doing this.

I'm trying this in my profile controller:

  def make @ profile = profile.find (param [: id]) type = param [: user] [: Profile_Aditors] [: type] if type & amp; Amp; ["Artist", "Listener"] Include (type) @ profile.update_editrid (: type, type) end of end   

and this user new view in my form: < Pre> & lt;% = form_for (setup_user (@user)) f | F | & 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; P & gt; Artist: & lt;% = t.radio_button: type, "artist"%> & Lt; / P & gt; & Lt; P & gt; Audience: & lt;% = t.radio_button: type, "listener"%> & Lt; / P & gt; & Lt; / Div & gt; & Lt;% end% & gt; ... & lt;% end% & gt;

and in my App Assistant:

  def setup_user (user) user.tap do | U | U.build_profile if u.profile.nil? End end   

I can not find the type set when the user is created. This is still the default for zero why is this and how can I complete it? I appreciate a code example.

UPDATE:

This is the relevant code in my user model:

  is_one: acceptable for profile_cent_data_profile: Profile_Next: build_profile   

2 update: I get this error: Warning: Can not consider protected attributes: type

profile_type = params [: user] [: profile] [:

Type] .consta Net If [ "artist", "listener"]. Include? Profile_type @profile = current_user.profile = profile_type.new current_user.save! Else flash [: warning] = "profile type is not supported" and end

Update: This is not really necessary, useful code might be, but it is not necessary to solve the above problem.

Comments