It sounds to me like Users have Players is your nesting. Also, you seem to have a "has_many :through" join setup but have implemented a basic "has_many". Consider this change....
class Player < ActiveRecord::Base ... has_many :trackers has_many :users, :through => :trackers ... end class User < ActiveRecord::Base ... has_many :trackers has_many :players, :through => :trackers ... end class Tracker < ActiveRecord::Base ... belongs_to :user belongs_to :player ... end On Dec 8, 5:11 pm, lunaclaire <[EMAIL PROTECTED]> wrote: > I'm currently in my first app desgined using REST and after reading a > few tutorials the basics are pretty clear, but I have a design problem > that I bet is common, but I'm not sure of the best approach... > > Here are my classes/resources: > > class Player < ActiveRecord::Base > ... > has_many :trackers > ... > end > > class User < ActiveRecord::Base > ... > has_many :trackers > ... > end > > class Tracker < ActiveRecord::Base > ... > belongs_to :user > belongs_to :player > ... > end > > I had no problem doing the basic generation of scaffolding and > building out functionality for Player and User, but now that I'm > building out the Trackers that allow a User to track a Player, I'm > confused. > > I thought at first that maybe I'd set it up as a nested resource, but > that's not making sense to me because a Tracker belongs to both a User > and a Player. > > Also, from a user story design perspective, the basic thing here is > that a user should be able to track a listed or displayed Player. So, > I think one of the views will display lists of Players with each > having a "Track" button or link next to them. I'd guess this will make > use of a "new_tracker_path", but that would need to pass params for > *both* the current User and the selected Player... right? (I tried it > with just passing the Player ref and thought I could just deal with my > @current_user variable in the controller, but something wasnt right) > > So, can anyone help with advice on best practices for this kind of > design where a resource is joining two other resources? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

