Need help with many-to-many relationships

Being new to Rails, I would appreciate some help defining some database
table relationships. I have the following tables:

waypoints
id
name

routes
id
name

routepoints
route_id
waypoint_id
seqno

This leads to the Rails associations:

waypoints
has_and_belongs_to_many :routes, :join_table => “routepoints”

routes
has_and_belongs_to_many :waypoints, :join_table => “routepoints”

My problem is that routepoints defines an ordered list of waypoints for
a given route (using “seqno”). Is it possible to use acts_as_list
somehow? I will also need other attributes of routepoints (like
estimated time enroute, fuel burn, etc.).

Any ideas appreciated!

ewo wrote:

Being new to Rails, I would appreciate some help defining some database
table relationships. I have the following tables:

My problem is that routepoints defines an ordered list of waypoints for
a given route (using “seqno”). Is it possible to use acts_as_list
somehow? I will also need other attributes of routepoints (like
estimated time enroute, fuel burn, etc.).

You’ll want to use has_many :through associations and a join model. Read
the API docs, read the wiki, read my blog.

http://blog.hasmanythrough.com/articles/2006/04/20/many-to-many-dance-off


Josh S.
http://blog.hasmanythrough.com

Thanks, Josh. Exactly what I needed…

–Eric