This project is archived and is in readonly mode.
NameError after creating scaffolding for object "Dive"
-
Daniel Rice
To workaround the issue, I have simply renamed the model to a non *ive word and used a route.rb redirect to get mysite/dives to work.
-
Jacek Becela
It looks like some issue with Inflector. Maybe somewhere near "knife => knives"
-
Bob Showalter
- Tag set to patch
Jacek is right; the problem is with the Inflector:
$ script/console >> "dive".pluralize.singularize => "dife"
The rules are a little too aggressive with the "ves" => "fe" conversion. "waves" -> "wafe", "stoves" -> "stofe", etc.
The attached patch adjusts the rules to better match the general case and handles the above conversions correctly. Additional test cases added.
-
Bob Showalter
Hmm, I see from the rails core archives that the inflector is basically "frozen", so this patch may not be accepted.
The rules can be applied locally if desired to handle some of the odd cases that the inflector doesn't handle well.
-
Daniel Rice
Hi Bob,
I saw the diff file, but could you please post your patched inflector.rb to this ticket? I would like to try to give the patched inflector a try in my own environment since the workaround I have in place isn't ideal. If I run into any problems, I'll work on tweaking the regex's and post back my changes if any.
If the inflector is "frozen" there might be a rails 2.2 release in the works or coming soon. That file should be patched to correctly work with English grammar eventually.
-
Bob Showalter
Daniel,
Much safer for you to just run patch against my diff like this:
patch < inflector_changes_for_ves.diff
It will ask you which file you want to patch; just point to your inflections.rb.
- Bob
-
Daniel Rice
Thanks Bob. I'm pretty new to RoR and haven't dug into the core very much at all. This is my first attempt at patching my own issue and digging into the rails source code.
thanks for the update on this one for sure. I do appreciate the replies.
-
Daniel Rice
I added a manual fix to my projects configs\initializers\inflections.rb file instead of patching.
configs\initializers\inflections.rb: Inflector.inflections do |inflect|
inflect.plural 'dive', 'dives' inflect.singular 'dives', 'dive'end
results in script\console doing this:
"dive".pluralize.singularize => "dive"
