I´m aware that Pluralization can be turned-off, but I was wondering why it was created ... just a convention? wouldn´t it be easier if we followed a convention like models and tables in singular, but models with initial capped? ex: Person(class)/person(table)? ... just curious ... -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, I would say that it''s a rule that your model names are singlular and your table names are plural within rails. If you follow the rule set forth, then life is made easier. Also, it was design to be English like if you read the model''s associations. Next, we don''t explicity reference the tables names within the models but we setup associations to other models using the proper syntax. Finally, you''re free to use non-standard table names as well as turn off pluralization within rails. Good luck, -Conrad On 3/17/07, Ken Awamura <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I´m aware that Pluralization can be turned-off, but I was wondering why > it was created ... just a convention? wouldn´t it be easier if we > followed a convention like models and tables in singular, but models > with initial capped? ex: Person(class)/person(table)? ... just curious > ... > > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ken Awamura wrote: I''m aware that Pluralization can be turned-off, but I was wondering why it was created ... just a convention? wouldn´t it be easier if we followed a convention like models and tables in singular, but models with initial capped? ex: Person(class)/person(table)? ... just curious Firstly, Ruby requires constants, like class names, to begin with a capital letter, and other things not to. Next, the best way to write a program is for a human to read. Any fool can write a program that a computer can read. Communicating with other humans is a major problem in all computing. So consider the SQL statement CREATE TABLE users. Without regards to Rails, should that say ''user'' or ''users''? There are many users in the table. But you might write SELECT users.name, which looks odd (and not possessive). So Rails splits this difference by attempting to match the plurality of a table name to its local context. User.find(:all) finds all users. belongs_to :user links your table''s items to one user in the users table. has_and_belongs_to_many :users links your table items to many users in the users table. And so on. The system is not perfect, but it leads one to consider - how literate could my own program be? Could I make my program literate, even at the level of statements'' grammar? -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi -- On 3/17/07, Phlip <phlip2005-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Ken Awamura wrote: > > I''m aware that Pluralization can be turned-off, but I was wondering why it > was created ... just a convention? wouldn´t it be easier if we followed a > convention like models and tables in singular, but models with initial > capped? ex: Person(class)/person(table)? ... just curious > > Firstly, Ruby requires constants, like class names, to begin with a capital > letter, and other things not to.Method names can begin with a capital letter too. (Not a practice I''m eager to encourage, but it''s possible :-) David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
hi Phlip That´s a good explanation ... so we have a more ''semantic'' code and that´s good. -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David A. Black wrote:> Method names can begin with a capital letter too. (Not a practice I''m > eager to encourage, but it''s possible :-)I thought when you call them, foo.Bar(), that''s when the interpretter trips over them. -- Phlip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Mar 17, 2007, at 23:32, Ken Awamura wrote:> I´m aware that Pluralization can be turned-off, but I was wondering why > it was created ... just a convention? wouldn´t it be easier if we > followed a convention like models and tables in singular, but models > with initial capped? ex: Person(class)/person(table)? ... just curious > ...http://weblog.rubyonrails.com/2005/08/25/10-reasons-rails-does- pluralization/ :) --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi -- On 3/18/07, Phlip <phlip2005-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > David A. Black wrote: > > > Method names can begin with a capital letter too. (Not a practice I''m > > eager to encourage, but it''s possible :-) > > I thought when you call them, foo.Bar(), that''s when the interpretter > trips over them.No, they work: $ ruby -e ''a=""; def a.X; 1; end; p a.X'' 1 David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.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 -~----------~----~----~----~------~----~------~--~---