Ruby on Rails is becoming more and more popular and whilst it remain a very powerful tool in any web developer’s arsenal it is still a young framework.
Rails v 2.0 will be a milestone release not only due to a great many enhancements but due to a change in the default behaviour of the ’scaffold’ creation – the default scaffold command will produce a RESTful framework for the model, controller and views. At the moment, you have to give a specific command (scaffold_resource) to have a RESTful outline automatically created.
However, this is not about the future (no matter how exciting that may be), it is about the present and one of the things that many people have some difficulty understanding: Active Record.
Exactly how does the database relationship work?
Do I need a has_one or a belongs_to relationship? And what is this ‘through’ that I hear about?
Well, Rails Envy has created an excellent video which explains many of these aspects from the basics to more advanced usage.
The video is 25 minutes long and, if you want a laid back and interesting lunch break, give it a shot.
The video covers:
Oh, it even has the code available as a download (direct link).
I think it is well worth a shot – even if you are happy with using these terms, it may well produce one of those great “I didn’t know that” moments.