title: Nested forms in rails - accessing attribute in has_many relation
body: <p>I have a user and a profile model. One user can have many profiles. I need to access only one information from the profiles section (viz the phone number) in my user model during the user creation process. Hence I'm trying to get it done through <code>attr_accessible</code>. My user.rb looks like this.</p>
  
  <pre><code>has_many :profiles
  attr_accessible :handle, :email, :password, :profile_mobile_number
  attr_accessor : :profile_mobile_number
  </code></pre>
  
  <p>The problem that I'm facing is that when I try to call the getter method profile_mobile_number in a method in user.rb (the method is private, though I think it doesn't matter), I'm getting a null value. I use the following in my users/new.html.erb form</p>
  
  
    
  
  <p>My question is what is the right way to do this? Should I use <code>&lt;% f.fields_for :profile do |ff| -%&gt;</code> or <code>&lt;% f.fields_for :profiles do |ff| -%&gt;</code> (notice that the second one is plural). When I use the plural :profiles, I don't even see the fields on the form. What am I missing here? And what is the tense that needs to be used in model user.rb? :profile_phone_number or :profiles_phone_number? Thanks.</p>