How do I create many-one relationships using Scaffold?

Posted by Simon on Stack Overflow See other posts from Stack Overflow or by Simon
Published on 2010-04-04T17:14:43Z Indexed on 2010/04/04 17:23 UTC
Read the original article Hit count: 394

I'm new to Ruby on Rails, and I'm trying to create a bass guitar tutor in order to teach myself RoR (and bass guitar). The walkthroughs use Scaffold to create ActiveRecord classes, but they seem to correspond to standalone tables; there's no use of belongs_to or has_many.

I'd like to create three classes: Scale, GuitarString, and Fret. Each Scale has many GuitarStrings, which each have many Frets.

How do I create classes with this relationship using Scaffold? Is there a way to do it in one go, or do I need to create them in an unrelated state using Scaffold, then add the relations by hand? Or should I ditch Scaffold entirely?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about activerecord