Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Singular option unavailable in the new Routes

#4311

In Rails 2.3:

map.resources :teeth, :singular => "tooth"

Generates the following:

           GET    /teeth(.:format)          {:action=>"index", :controller=>"teeth"}
     teeth POST   /teeth(.:format)          {:action=>"create", :controller=>"teeth"}
 new_tooth GET    /teeth/new(.:format)      {:action=>"new", :controller=>"teeth"}
           GET    /teeth/:id(.:format)      {:action=>"show", :controller=>"teeth"}
           PUT    /teeth/:id(.:format)      {:action=>"update", :controller=>"teeth"}
     tooth DELETE /teeth/:id(.:format)      {:action=>"destroy", :controller=>"teeth"}
edit_tooth GET    /teeth/:id/edit(.:format) {:action=>"edit", :controller=>"teeth"}

In Rails 3, passing :singular as an option generates the following:

           GET    /teeth(.:format)          {:action=>"index", :singular=>"tooth", :controller=>"teeths"}
    teeths POST   /teeth(.:format)          {:action=>"create", :singular=>"tooth", :controller=>"teeths"}
 new_teeth GET    /teeth/new(.:format)      {:action=>"new", :singular=>"tooth", :controller=>"teeths"}
           GET    /teeth/:id(.:format)      {:action=>"show", :singular=>"tooth", :controller=>"teeths"}
           PUT    /teeth/:id(.:format)      {:action=>"update", :singular=>"tooth", :controller=>"teeths"}
     teeth DELETE /teeth/:id(.:format)      {:action=>"destroy", :singular=>"tooth", :controller=>"teeths"}
edit_teeth GET    /teeth/:id/edit(.:format) {:action=>"edit", :singular=>"tooth", :controller=>"teeths"}

Also, I checked if there's a singular method, but that returns a NoMethodError. Is this something we would like to support with the new DSL?

Reported by Rizwan Reza · April 2nd, 2010 @ 12:20 PM

State: wontfix
Milestone: 3.0.2
Assigned to: DHH DHH
Importance: Medium

Activity

  1. Andrew White
    Andrew White

    I saw it was missing the other day and thought about adding a patch, but I got the impression that the preferred method was to add a custom inflection.

    I'll add a patch this evening and leave it up to core to decide what to do with it.

    April 3rd, 2010 @ 07:21 AM

  2. DHH
    DHH

    I'm not sure I understand the value of this. It looks like all this does is change the name of the named route. What's the purpose here?

    April 3rd, 2010 @ 07:02 PM

  3. Rizwan Reza
    Rizwan Reza

    It fixes it when the singular-plural algorithm fails. It's your call. :)

    April 3rd, 2010 @ 07:05 PM

  4. DHH
    DHH

    Ahh, okay. Well, you really should fix that in config/initializers/inflections.rb. Otherwise it's not going to be consistent in the rest of your app. I don't think we need it here unless there are other arguments for it.

    April 3rd, 2010 @ 07:06 PM

  5. Rizwan Reza
  6. Rizwan Reza
    Rizwan Reza
    • State changed from open to wontfix

    April 3rd, 2010 @ 07:12 PM

  7. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Medium

    October 15th, 2010 @ 11:01 PM