I have just discovered Ruby on Rails and I have been going through the
tutorial "Rolling with Ruby on Rails revisited".
One thing that baffles me is that we create my sql tables "recipes"
and "categories". We then generate ruby scaffold using the command
ruby script/generate scaffold recipe recipe
ruby script/generate scaffold category category
As you can see that the model and controller arguments are spelt
differently from the database table names. How does the framework
associate the right table to the right model and controller classes.
Moving further on in the tutorial I notice that the model classes
Category and Recipe have the following line of code added to them-
class Category < ActiveRecord::Base
has_many : recipes
class Recipe < ActiveRecord::Base
belongs_to : category
It looks like that the framework uses "recipes" and "recipe" &&
"category" and "categories" interchangeably.
Can someone throw some light on this issue?