title: Rails 4 - how to display a collection of associated content in a view
body: <p>I'm trying to figure out how to display a collection of associated data in my view.</p>
  
  <p>I have models for User, Profile and Evaluation.</p>
  
  <p>The associations are:</p>
  
  <p>User </p>
  
  <pre><code>has_one :profile
  has_many :given_evaluations, foreign_key: :evaluator_id, dependent: :destroy, class_name: Evaluation
    has_many :received_evaluations, foreign_key: :evaluatee_id, dependent: :destroy, class_name: Evaluation
  </code></pre>
  
  <p>Profile </p>
  
  <pre><code>belongs_to :user
  </code></pre>
  
  <p>Evaluation </p>
  
  <pre><code>belongs_to :evaluator, foreign_key: :evaluator_id, class_name: User
    belongs_to :evaluatee, foreign_key: :evaluatee_id, class_name: User
  </code></pre>
  
  <p>In my profile show, I'm trying to show a user's received evaluations. I think the following is correct, although it's not working.</p>
  
  <pre><code>&lt;% @profile.user.received_evaluations.each do | receval | %&gt;
                          &lt;ul class="testimonial-slider text-white text-center"&gt;
                              &lt;li&gt;
                                  &lt;div class="testimonial-content"&gt;
                                      &lt;%= receval.remark %&gt;
                                  &lt;/div&gt;
  </code></pre>
  
  <p>I can see in my rails console, that this user has 1 received evaluation:</p>
  
  <pre><code> p.user.received_evaluations
       =&gt; #&lt;ActiveRecord::Associations::CollectionProxy [#&lt;Evaluation id: 4, evaluatee_id: 34, overall_score: nil, project_score: nil, personal_score: nil, remark: "testing", work_again?: nil, continue_project?: nil, created_at: "2016-06-03 08:15:04", updated_at: "2016-06-03 08:15:04", evaluator_id: nil&gt;]&gt; 
  </code></pre>
  
  <p>The remark in that evaluation is "testing".</p>
  
  <p>When I try this - the profile view renders, but the remark does not show. It's just a blank view.</p>
  
  <p>Can anyone see what I've done wrong?</p>
  
  <p>I have tried each of the following the code (without the html and styling), but in each case, I get a "no method error for remark". I can't figure out what that error message means - remark is not a method.</p>
  
  <pre><code>&lt;%= @profile.user.received_evaluations.first.try(:remark) %&gt;
  &lt;%= @profile.user.received_evaluations.try(:remark) %&gt;
  &lt;%= @profile.user.received_evaluations.remark %&gt;
  </code></pre>