This project is archived and is in readonly mode.

#1365 ✓duplicate
Wiktor Schmidt

member actions in resource routing does not respect requirements for :id

Reported by Wiktor Schmidt | November 13th, 2008 @ 12:44 PM | in 2.x

  map.resources       :users,
                      :member => {:report => :get},
                      :requirements => {:id => /[+.a-z]+/}

/users/ - works correctly

/users/ - gives route not found

Comments and changes to this ticket

  • Wiktor Schmidt

    Wiktor Schmidt November 13th, 2008 @ 12:51 PM

    How to fix it: in resources.rb:

    in method action_options_for lines:

              else                  default_options.merge(add_conditions_for(resource.conditions, method)).merge(resource.requirements)

    should look like

              else                  default_options.merge(add_conditions_for(resource.conditions, method)).merge(resource.requirements(require_id if this_is_a_member_action))

    I have no idea how make a "clean" this_is_a_member_action method...

    I quickly patched it by using a additional parameter for action_options_for:

          def action_options_for(action, resource, method = nil, member = false)
              else                  default_options.merge(add_conditions_for(resource.conditions, method)).merge(resource.requirements(require_id if member))

    and passing this parameter in map_member_actions:

          def map_member_actions(map, resource)
            resource.member_methods.each do |method, actions|
              actions.each do |action|
                action_options = action_options_for(action, resource, method, true)
  • Wiktor Schmidt
  • CancelProfileIsBroken

    CancelProfileIsBroken March 7th, 2009 @ 02:55 PM

    • State changed from “new” to “duplicate”

    Fixed on #2054

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=""></a>

People watching this ticket