title: Is it possible to display data through a id?
body: <p>My apologies for the abstract title. I'm in the proces of adding a friendship feature in my Rails/Angular application following <a href="http://railscasts.com/episodes/163-self-referential-association?autoplay=true" rel="nofollow">#163 Self-Referential Association</a>.</p>
  
  <p>With the help of some other users here I've created the option to add friends, but I'm having some trouble displaying the correct data (name, etc) in a friendslist.</p>
  
  <p>I have a <code>friendships</code> table,</p>
  
  <pre><code>create_table "friendships", force: :cascade do |t|
    t.integer  "user_id"
    t.integer  "friend_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end
  </code></pre>
  
  <p>When a friend is added it creates a new record in the table with a user id and a friend id.</p>
  
  <pre><code>{"id":1,"user_id":1,"friend_id":2,"created_at":"2015-12-29T13:18:44.499Z","updated_at":"2015-12-29T13:18:44.499Z"},
  {"id":2,"user_id":1,"friend_id":3,"created_at":"2015-12-29T13:18:45.463Z","updated_at":"2015-12-29T13:18:45.463Z"},
  {"id":3,"user_id":1,"friend_id":4,"created_at":"2015-12-29T13:18:46.420Z","updated_at":"2015-12-29T13:18:46.420Z"}
  </code></pre>
  
  <p>In the <code>friendships_controller.rb</code> I have,</p>
  
  <pre><code>def index
    friend = current_user.friendships
    render :json =&gt; friend.to_json()
  end
  </code></pre>
  
  <p>So I can see what <code>friend_id</code> is connected to a <code>user_id</code>. But if I want to display the friends in a ng-repeat I'm going to need more data. </p>
  
  <p>The <code>friend_id</code> is the added users id. So if a user adds the 4th user to his friendslist the friend_id would be 4. So it possible to connect that <code>friend_id</code> to the <code>user_id</code> so I can then show the <code>{{ user.name }}</code> or do I need to add all the data like name, birthday etc to the parameters of the friend create function?</p>
  
  <p>So for example I would add the friends name to the parameters so the JSON looks like this,</p>
  
  <pre><code>{"id":1,"user_id":1,"friend_id":2,"name":john,"created_at":"2015-12-29T13:18:44.499Z","updated_at":"2015-12-29T13:18:44.499Z"},
  {"id":2,"user_id":1,"friend_id":3,"name":david,"created_at":"2015-12-29T13:18:45.463Z","updated_at":"2015-12-29T13:18:45.463Z"},
  {"id":3,"user_id":1,"friend_id":4,"name":cash,"created_at":"2015-12-29T13:18:46.420Z","updated_at":"2015-12-29T13:18:46.420Z"}
  </code></pre>
  
  <p>Then I can do something like <code>ng-repeat friend in friendships</code> <code>{{ friend.name }}</code></p>