Singular form of model

Rails 3.1.3
ruby 1.9

I have a model called, "Give". I understand that it may not be a good
choice for a model, but couldn't be helped.

Rails seems to have recognized its singular form to be "gife" rather
than "give", which I hoped to be.
So, I put in routes.rb

  resources :gives, :singular => :give

But the routes still show

               new_gife GET /gives/new(.:format)
{:action=>"new", :controller=>"gives"}
               edit_gife GET /gives/:id/edit(.:format)
{:action=>"edit", :controller=>"gives"}
                    gife GET /gives/:id(.:format)
{:action=>"show", :controller=>"gives"}

Do I need to do something else to let it change the singular form of
"Gives" to be "give"?

Thanks.

soichi

Rails 3.1.3
ruby 1.9

I have a model called, "Give". I understand that it may not be a good
choice for a model, but couldn't be helped.

Rails seems to have recognized its singular form to be "gife" rather
than "give", which I hoped to be.
So, I put in routes.rb

resources :gives, :singular => :give

But the routes still show

              new_gife GET /gives/new(.:format)
{:action=>"new", :controller=>"gives"}
              edit_gife GET /gives/:id/edit(.:format)
{:action=>"edit", :controller=>"gives"}
                   gife GET /gives/:id(.:format)
{:action=>"show", :controller=>"gives"}

Do I need to do something else to let it change the singular form of
"Gives" to be "give"?

Wow, that is really odd. Gife isn't even a word, as far as I can tell. You can change this in the inflections.rb file in your config/initializers folder. It's pretty well commented and should work for this case.

Walter

Soichi Ishida wrote in post #1075000:

I have a model called, "Give". I understand that it may not be a good
choice for a model, but couldn't be helped.

You are right that "Give" is a really bad choice for a model name.
Models should be nouns not verbs (i.e. One gives a gift). The model
would be thing given not the act of giving.

That is a really odd inflection bug though. It must be triggering the
wrong inflection rule somehow.

It's probably got a rule to deal with plurals like knives, lives,
wives, etc. Seeing a table end in "ives" (and not triggering any
higher-priority rule) then makes sense.

Now to go munch on sour cream and chife potato chips, and listen to
some Burl Ife music.... :wink:

-Dave

Thanks everyone.

have added

ActiveSupport::Inflector.inflections do |inflect|
  inflect.irregular 'give', 'gives'
end

in the inflection.rb , then now

                   gives GET /gives(.:format)
{:action=>"index", :controller=>"gives"}
                         POST /gives(.:format)
{:action=>"create", :controller=>"gives"}
                new_give GET /gives/new(.:format)
{:action=>"new", :controller=>"gives"}
               edit_give GET /gives/:id/edit(.:format)
{:action=>"edit", :controller=>"gives"}
                    give GET /gives/:id(.:format)
{:action=>"show", :controller=>"gives"}

looking good!

Thanks again.

soichi