title: Rails 3 How to access user data from user_id column in belongs_to :user association
body: <p>I am trying to create an activity feed with the most recent activities from my TrainingSession model.</p>
  
  <pre><code>class User
    has_many :training_sessions
  end
  
  class TrainingSession
    belongs_to :user
  end
  </code></pre>
  
  <p>The problem is that I am trying to access a user's data in the view page (mainly the user's name) by instantiating an object from the TrainingSessions database table, as shown below:</p>
  
  <pre><code>&lt;% @training_sessions.each do |training_session| %&gt;
  &lt;%= training_session.user_id %&gt;
  </code></pre>
  
  <p>The problem is that, although I successfully get the user's id, I cannot call, for example:</p>
  
  <pre><code>training_session.user_id.name
  </code></pre>
  
  <p>... otherwise I get the NoMethodError shown below:</p>
  
  <pre><code>undefined method `first_name' for 2:Fixnum
  </code></pre>
  
  <p>so my question is ... how can I access the user's data from the TrainingSession's object?</p>
  
  <p>any help would be much appreciated. Pretty stumped on this one.</p>