title: Can't get my type attribute set in my Profile model for STI
body: <p>I have a <code>User</code> model which <code>has_one :profile</code>, and the <code>profile</code> model has a <code>type</code> column for Single Table Inheritance. I want a user to set <code>type</code> upon signing up, and I'm having trouble doing this.</p>
  
  <p>i'm trying this in my profiles controller:</p>
  
  <pre><code>def create
     @profile = Profile.find(params[:id])
     type = params[:user][:profile_attributes][:type]
     if type &amp;&amp; ["Artist","Listener"].include?(type)
      @profile.update_attribute(:type,type)    
     end
  end
  </code></pre>
  
  <p>and this in my form for the <code>User</code> new view:</p>
  
  <pre><code>&lt;%= form_for(setup_user(@user)) do |f| %&gt;
  ...
    &lt;%= 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;p&gt; Artist: &lt;%= t.radio_button :type, "Artist" %&gt;&lt;/p&gt;
      &lt;p&gt; Listener: &lt;%= t.radio_button :type, "Listener" %&gt;&lt;/p&gt;
    &lt;/div&gt;
    &lt;% end %&gt;
  ...
  &lt;% end %&gt;   
  </code></pre>
  
  <p>and in my application helper:</p>
  
  <pre><code>def setup_user(user)
    user.tap do |u|
      u.build_profile if u.profile.nil?
    end
  end
  </code></pre>
  
  <p>I can't seem to get <code>type</code> set when a User is created. It still defaults to <code>nil</code>. Why is this and how can I accomplish it? I'd appreciate a code example.</p>
  
  <p>UPDATE:</p>
  
  <p>This is the relevant code in my <code>User</code> model:</p>
  
  <pre><code>has_one :profile 
  accepts_nested_attributes_for :profile
  before_create :build_profile
  </code></pre>
  
  <p>UPDATE 2: I get this error: <code>WARNING: Can't mass-assign protected attributes: type</code></p>