This project is archived and is in readonly mode.
[PATCH] plural names generate a constant error
Reported by Daniel | August 16th, 2009 @ 11:50 PM
Greetings,
When I create a pre-plural-ized name with the scaffolding, I get an error like this:
-- start
NameError in PicturesController#index
uninitialized constant PicturesController::Pictures
-- end
Here are the steps to reproduce this problem:
-- START
rails test --database=mysql
cd test
rake db:create RAILS_ENV='development'
rake db:migrate
ruby script/generate scaffold user username:string
ruby script/generate scaffold pictures title:string
rake db:migrate
ruby script/server
-- END
http://localhost:3000/users ->
this works.
http://localhost:3000/pictures
-> this generates an const error.
OS: Ubuntu 9.04 "jaunty"
Ruby: 1.8.7 patchelevel 72
Rails: 2.3.3
--
If you need any more information, let me know.
-daniel
Comments and changes to this ticket
-
John Pignata August 17th, 2009 @ 02:48 AM
+1 Verified -- it appears to be an issue where the assign_names! method is called during initialize but never reset in the event that the model name was plural. My patch resets assign_names! in this case and added an assertion.
-
John Pignata August 17th, 2009 @ 04:02 AM
- Assigned user set to José Valim
- Tag changed from auto, const, error, generated, plural, scaffold to 2-3-stable, auto, const, error, generated, master, plural, scaffold
- Title changed from plural names generate a constant error to [PATCH] plural names generate a constant error
Here's a patch for master. Currently, plural names passed as models to the scaffold generator in master don't generate any files but instead crashes due to a related bug.
-
Kane August 26th, 2009 @ 01:48 AM
why do you think this should work?
"Pass the name of the model (in singular form), either CamelCased or under_scored, as the first argument, and an optional list of attribute pairs."
-
John Pignata August 26th, 2009 @ 02:08 AM
There's code in the generator now to handle the case when a plural name is passed - though it reports that it's reverting to singular it's simply not working:
jp@populuxe:~/Projects/scratch/test_scaffold$ script/generate scaffold cars warning Plural version of the model detected, using singularized version. Override with --force-plural.
-
José Valim August 30th, 2009 @ 04:40 PM
- Assigned user changed from José Valim to Jeremy Kemper
Fixed on master, must be merged soon. Just need to apply the patch in 2.3 stable.
-
Repository August 30th, 2009 @ 08:06 PM
(from [0efedf2a30a12cdaa261556e3684c630690afe0f]) Ensure scaffold works properly even if plural name is given. [#3062] http://github.com/rails/rails/commit/0efedf2a30a12cdaa261556e3684c6...
-
Repository August 30th, 2009 @ 09:31 PM
- State changed from new to committed
(from [ff8cb50f25e426c531743fbf918e2a870e60e0e8]) Ensuring that a singular model name is set for use in controllers when scaffold is passed a plural model name
[#3062 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/ff8cb50f25e426c531743fbf918e2a...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 3062 [PATCH] plural names generate a constant error (from [0efedf2a30a12cdaa261556e3684c630690afe0f]) Ensure ...
- 3062 [PATCH] plural names generate a constant error [#3062 state:committed]