So thanks guys - here is the real fix:
class Team < ActiveRecord::Base
has_many :schedules
has_many :opponents, :through => :schedules
end
class Schedule < ActiveRecord::Base
belongs_to :team
belongs_to :opponent, :class_name => "Team"
end
And in my schedules controller I have:
def index
@schedules = Schedule.all :include => [:team, :opponent]
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @schedules }
end
end
And in my views I can call it by:
<% @schedule.each do |schedule| %>
schedule.team.name
schedule.opponent_id
schedule.opponent.name
<% end %>
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---