How to get assocated model's attribute values in views ? Rails
<p>I have three models...</p>

<p><strong><em>models/resident.rb</em></strong></p>

<pre><code>class Resident &lt; ActiveRecord::Base
  belongs_to :hostel
  has_many :leaves,dependent: :delete_all
  has_one :user,dependent: :delete
end
</code></pre>

<p><strong><em>models/user.rb</em></strong></p>

<pre><code>class User &lt; ActiveRecord::Base
  belongs_to :resident
end
</code></pre>

<p><strong><em>models/leave.rb</em></strong></p>

<pre><code>class Leave &lt; ActiveRecord::Base
  belongs_to :resident
end
</code></pre>

<p>Now when I am trying to access the value of leave's attribute in <strong><em>views/leave/show.html.erb</em></strong>
I am getting this:</p>

<p><strong><em>app/views/leaves/show.html.erb</em></strong></p>

<pre><code>&lt;%= @leaves %&gt;
</code></pre>

<p>out put In Browser :</p>

<pre><code>#&lt;Leave::ActiveRecord_Associations_CollectionProxy:0x007fde611850f0&gt; 
</code></pre>

<p>My leave controller looks like :
<strong><em>leaves_controller.rb</em></strong></p>

<pre><code>class LeavesController &lt; ApplicationController

  def new
    if logged_in?
       @leave=Leave.new
    else
      flash[:info]="Please login to mark a leave"
      redirect_to root_path
    end
  end
   def show
     @leaves= current_user.resident.leaves
   end

  def create
    @leave=current_user.resident.leaves.create(leave_params)
    if @leave.save
      flash[:info] = "Leave successfully marked"
      redirect_to new_leave_path
    else
      flash[:danger] = "Something wrong Happened try again"
      redirect_to root_path
    end
  end

  private
  def leave_params
    params.require(:leave).permit(:start_date,:end_date,:destination)
  end
end
</code></pre>

<p>Am I making correct leaves for resident and related user <strong><em>(create method)</em></strong>?</p>

<p>Is show method correct ?</p>

<p>and How to assess the user's leaves attribute in <strong><em>show.html.erb</em></strong> of leaves views.</p>