I have just discovered Ruby on Rails and I have been going through the tutorial "Rolling with Ruby on Rails revisited". http://www.onlamp.com/pub/a/onlamp/2006/12/14/revisiting-ruby-on-rails-revisited.html 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 end class Recipe < ActiveRecord::Base belongs_to : category end It looks like that the framework uses "recipes" and "recipe" && "category" and "categories" interchangeably. Can someone throw some light on this issue? Thank you, S --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This is the "famous" convention over configuration. Rails uses a heuristic that says "pluralize my model name to find the table name" (and similarly, singularize the table name to find my model name". Its knowledge of appropriate plural identifiers is quite broad, hence the category cleverness. See the Infector module in the API docs. for more information. Wes -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
er, Inflector :). -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---