What’s Missing?

At this point, you should be starting to get a sense of what’s involved in building a real Rails application. These examples really just scratch the surface, both of what’s necessary and of what’s possible.

While the students and courses application has gone much further into Rails than previous applications, it’s still largely built on the scaffolding. The connections between course and student interfaces could be deepened. The new methods, while certainly functional, don’t follow the same clean architectural lines that their RESTful predecessors had, taking a more direct path to getting things done. And finally, they don’t offer the same XML-in/XML-out functionality of their RESTful predecessors.

There are also a few more relationships you can explore as you get further into Rails development. The has_and_belongs_to_many relationship can be used, for example, to connect a table to foreign keys in the same table, creating a self-referential join. There’s also has_many :through, which lets you connect one table to another through an intermediate table, rather than directly with a foreign key. And finally, there’s has_one, which is much like has_many, but limits itself to one connection.

Which of those opportunities are priorities for you depends on the needs of your own application. You may have related tables that need only occasional connections, or tables whose connections aren’t modified directly by users. An XML-based API may be central for ...

Get Learning Rails now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.