This might be of use to you: 
http://blog.hasmanythrough.com/2007/10/30/self-referential-has-many-through 
  because you are doing a self-referential join through the schedules  
table.

Worry out the routing after your models are behaving correctly (maybe  
a passing test or two?).

Hope this helps


On Jul 11, 2009, at 11:59 AM, Älphä Blüë wrote:

>
> Älphä Blüë wrote:
>> So..
>>
>> class Team
>>  has_many :schedules
>>  has_many :opponents :through => :schedules
>> end
>>
>> class Schedule
>>  belongs_to  :team
>>  belongs_to  :opponent, :class_name => "Team"
>> end
>
> And using this,
>
> how do I reference opponents in my RESTful methods?
>
> For instance, doing this, when I refresh my index page for schedules  
> it
> shows both the opponents and opponent_id fields empty in my table.
> However, I've populated a few of them already in my database.
>
> def Index
> @schedules = Schedule.all
> end
>
> That's what I have currently and it doesn't find opponent or
> opponent_id, even though they are listed in the schedules table.
>
> -- 
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to