(I think I''ll be wishing frequently, but only because I love.) So, I''ve gotten bitten in the end a bit by feeling confused about plurals vs singulars. I generate a scaffold for Thing, and that gives us: - controller: things - view: things - model: *thing* Which seems to mean (in my experience) that I while I can say "has_one :thing", I also have to say "has_many :thing" when I really want to say ":things". And also, we did a much of mistakes in trying to generate a scaffold for Things instead of Thing, and then we had to fiddle around on re-standardizing all that. I could see it being helpful if there was a option (albeit a very optional one!) that Rails could make assumptions about your singulars and plurals - i.e. if the /object/ controller failed to resolve it might try /objects/. I don''t think this is necessarily bad design - you probably shouldn''t be naming your objects so similarly if you can help it right? Is this implementable in some way? -d
Dev, Not exactly an answer to your question but when I use the generate scaffold script I use it in this manner: ./script/generate scaffold Thing Thing Usage: ./script/generate scaffold ModelName [ControllerName] [action, ...] This will create the controller and model in the singular. It has saved me alot of headaches. -Brandon On 00:41 Mon 04 Apr , Dev Purkayastha wrote:> (I think I''ll be wishing frequently, but only because I love.) > > So, I''ve gotten bitten in the end a bit by feeling confused about > plurals vs singulars. I generate a scaffold for Thing, and that gives > us: > - controller: things > - view: things > - model: *thing* > > Which seems to mean (in my experience) that I while I can say "has_one > :thing", I also have to say "has_many :thing" when I really want to > say ":things". And also, we did a much of mistakes in trying to > generate a scaffold for Things instead of Thing, and then we had to > fiddle around on re-standardizing all that. > > I could see it being helpful if there was a option (albeit a very > optional one!) that Rails could make assumptions about your singulars > and plurals - i.e. if the /object/ controller failed to resolve it > might try /objects/. I don''t think this is necessarily bad design - > you probably shouldn''t be naming your objects so similarly if you can > help it right? > > Is this implementable in some way? > > -d > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-- Brandon Philips brandon-CJG/fkoVOTIdnm+yROfE0A@public.gmane.org "Open minds. Open doors. Open source." - osuosl.org _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On Apr 4, 2005 5:41 PM, Dev Purkayastha <dev.purkayastha-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> (I think I''ll be wishing frequently, but only because I love.) > > So, I''ve gotten bitten in the end a bit by feeling confused about > plurals vs singulars. I generate a scaffold for Thing, and that gives > us: > - controller: things > - view: things > - model: *thing* > > Which seems to mean (in my experience) that I while I can say "has_one > :thing", I also have to say "has_many :thing" when I really want to > say ":things". And also, we did a much of mistakes in trying to > generate a scaffold for Things instead of Thing, and then we had to > fiddle around on re-standardizing all that.has_many :things works find for me, as does has_and_belongs_to_many :things -- Phillip Hutchings http://www.sitharus.com/ sitharus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org / sitharus-QrR4M9swfipWk0Htik3J/w@public.gmane.org
> ./script/generate scaffold Thing Thing > > Usage: ./script/generate scaffold ModelName [ControllerName] [action, > ...]That would indeed get rid of some future headaches, although I still feel like that might be interesting magic if they could be understood to be the same thing. For me, I always thought that "Keyboards.find_all" scanned better than "Keyboard.find_all" - enough to possibly make me aliases. As for has_many :things, thanks for letting me know! I wonder how I got the impression otherwise... d
Dev Purkayastha wrote:> For me, I always thought that > "Keyboards.find_all" scanned better than "Keyboard.find_all" - enough > to possibly make me aliases.Put a "Keyboards = Keyboard" below the definition of the Keyboard class in your model file and both will work.
On Apr 4, 2005 10:03 AM, Florian Groß <florgro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Put a "Keyboards = Keyboard" below the definition of the Keyboard class > in your model file and both will work.Is that actually an alias, or does that create a second, identical model? If the latter, it seems like there''d be huge performance penalties as rails tries to work it''s magic twice over instead of just the once. -- Urban Artography http://artography.ath.cx
On Apr 4, 2005 6:25 PM, Rob Park <rbpark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Apr 4, 2005 10:03 AM, Florian Groß <florgro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Put a "Keyboards = Keyboard" below the definition of the Keyboard class > > in your model file and both will work. > > Is that actually an alias, or does that create a second, identical > model? If the latter, it seems like there''d be huge performance > penalties as rails tries to work it''s magic twice over instead of just > the once.Ruby assigns by reference, so this is just a pointer. Regards, -JD-