Rails - Disturbance of relationship attributes

advertisements

Those are my models:

class Person < ActiveRecord::Base
  has_many :honors, :dependent => :destroy, :foreign_key => "honored_id"
  has_many :honor_creators, :through => :honors, :source => :person, :foreign_key => "person_id"

class Group
  has_many :honorss,:foreign_key => "group_id"

class Honor
  belongs_to :person, :class_name => 'Person', :foreign_key => "person_id"
  belongs_to :honored, :class_name => 'Person', :foreign_key => "honored_id"
  belongs_to :group, :class_name => 'Group', :foreign_key => "group_id"

Since the honors are shown at the person#show page, here is my controller:

def show
  ...
  @honors = @person.honors.paginate(:page => params[:page], :per_page => Honor.per_page)
end

And my view:

<% unless @honors.empty? %>
<% @honors.each do |ho| %>

My question is: using the ho I get all the attributes from the honor, but I want to get the creater of the honor and the group that it belongs. How can I do that?

Thanks!


You can do that by accessing

ho.person

or

ho.group