Hi, Is there a definitive list of reserved words I should avoid when naming "things" in my Rails apps? For example, I''ve just run into a couple of problems that are (I think) name-related. 1. I wanted to create the following model: Projects -->> Actions But this caused problems with the "Action" name. 2. The project table had the following structure: id code name But Rails didn''t like the "name" field. I changed that to fullname and it worked. Thanks, R. -- http://robinbowes.com If a man speaks in a forest, and his wife''s not there, is he still wrong?
Robin Bowes wrote:> Hi, > > Is there a definitive list of reserved words I should avoid when > naming "things" in my Rails apps?Here''s _a_ list: http://wiki.rubyonrails.com/rails/show/ReservedWords> But Rails didn''t like the "name" field. I changed that to fullname and > it worked.Hmm. I use ''name'' all over the place and that seems to work OK to me. ...j
On Thu, 28 Jul 2005, Jamie Wilson wrote:> Robin Bowes wrote: > >> Hi, >> >> Is there a definitive list of reserved words I should avoid when naming >> "things" in my Rails apps? > > Here''s _a_ list: > > http://wiki.rubyonrails.com/rails/show/ReservedWordsAnd I think if you have a column in a table matching /.*_id/, for example we''ve been given a table with ''institution_id'', I think that will cause pain as well. But I''m still learning all this stuff...>A lint for Rails would be nice. (MixedMetaphorException: it would probably need to be named after the people that walk the tracks to inspect them, since picking fluff off rails isn''t a common activity.) Hugh
> >> > >> Is there a definitive list of reserved words I should avoid when naming > >> "things" in my Rails apps? > >I mentioned this a couple of days ago, but it is also a bad idea to name a model with the same name as a subdirectory of your controllers directory. Rails gets very confused with that. Shelby
Jamie Wilson wrote:> Robin Bowes wrote: > >> Hi, >> >> Is there a definitive list of reserved words I should avoid when >> naming "things" in my Rails apps? > > > Here''s _a_ list: > > http://wiki.rubyonrails.com/rails/show/ReservedWordsThanks.> >> But Rails didn''t like the "name" field. I changed that to fullname and >> it worked. > > > Hmm. I use ''name'' all over the place and that seems to work OK to me.Hmmmm... I just tried again and both worked fine, i.e. a table called "actions" and a column called "name". Must have been doing something else wrong. R. -- http://robinbowes.com If a man speaks in a forest, and his wife''s not there, is he still wrong?
On 28.7.2005, at 16.49, Hugh Sasse wrote:> And I think if you have a column in a table matching /.*_id/, for > example we''ve been given a table with ''institution_id'', I think that > will cause pain as well.It won''t as long as it''s a foreign key field referencing table ''institutions'' :-). In that case it''s exactly the convention you should be following with Rails. If it isn''t a foreign key field, it''s a bad name anyway because it certainly looks like a fk. //jarkko _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On Thu, 28 Jul 2005, Jarkko Laine wrote:> On 28.7.2005, at 16.49, Hugh Sasse wrote: > >> And I think if you have a column in a table matching /.*_id/, for >> example we''ve been given a table with ''institution_id'', I think that >> will cause pain as well. > > It won''t as long as it''s a foreign key field referencing table ''institutions'' > :-). In that case it''s exactly the convention you should be following with > Rails. If it isn''t a foreign key field, it''s a bad name anyway because it > certainly looks like a fk.Outside of Rails, it''s a good name for "a numeric id issued by the institution", which is what it means in our case. I''m calling it something else now.> > //jarkkoHugh
Might be a good idea to take the list from the wiki and syntax highlight it with a glaring, evil red. - Ben On Jul 28, 2005, at 10:19 AM, Robin Bowes wrote:> Hi, > > Is there a definitive list of reserved words I should avoid when > naming "things" in my Rails apps? > > For example, I''ve just run into a couple of problems that are (I > think) name-related. > > 1. I wanted to create the following model: > > Projects -->> Actions > > But this caused problems with the "Action" name. > > > 2. The project table had the following structure: > > id > code > name > > But Rails didn''t like the "name" field. I changed that to fullname and > it worked. > > Thanks, > > R. > -- > http://robinbowes.com > > If a man speaks in a forest, > and his wife''s not there, > is he still wrong? > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >___________________ Ben Jackson Diretor de Desenvolvimento +55 (21) 9997-0593 ben-p14LI7ZcAE/pVLaUnt/cCQC/G2K4zDHf@public.gmane.org http://www.incomumdesign.com