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.