title: Delegated with nil property in ruby
body: <p>For some reason that I am not understanding I get this error message when running a certain page on my app:</p>
  
  <pre><code>Teamplayer#Plyr delegated to live_player.Plyr, but live_player is nil: #&lt;Teamplayer id: 1, playerid: "2533033", teamid: "1", live_player_id: 253303, fteam_id: "1", created_at: "2014-05-12 13:57:49", updated_at: "2014-05-12 13:57:49"&gt;
  </code></pre>
  
  <p>On this line:</p>
  
  <pre><code>&lt;%= @teamplayer.Plyr %&gt;
  </code></pre>
  
  <p>Here is how my model for Teamplayer is set up:</p>
  
  <pre><code>class Teamplayer &lt; ActiveRecord::Base
  belongs_to :live_player
  belongs_to :fteam
      delegate :Plyr, to: :live_player
  delegate :Team, to: :live_player
  delegate :Nid, to: :live_player
  delegate :name_team, to: :live_player
  delegate :fanteam, to: :fteam
  
  end
  </code></pre>
  
  <p>Here is the Liveplayer model:</p>
  
  <pre><code>class LivePlayer &lt; ActiveRecord::Base
  has_many :fteams, through:  :teamplayers
  end
  </code></pre>
  
  <p>Here is the Fteam model since it is mentioned above:</p>
  
  <pre><code>class Fteam &lt; ActiveRecord::Base
  has_many :teamplayers
  has_many :live_players, through: :teamplayers
  end
  </code></pre>
  
  <p>I am trying to get the field Plyr from live_player (which comes from the table called live_players), but it is saying that the live_player is empty. I am not sure which part of this is wrong. I am using postgresql, but I don't think that has an effect on it.</p>
  
  <p>If anyone needs more information to help me with this, I will be more then happy to post it</p>