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.

Resources is not passing all options to yield

#4475

Reported by Daniel Libanori · April 26th, 2010 @ 03:14 AM

State: resolved
Milestone: none
Assigned to: Andrew White Andrew White
Importance: Low

Activity

  1. Daniel Libanori
    Daniel Libanori
    • Tag set to rails3 routes

    At actionack/lib/action_dispatch/routing/mapper.rb, resources pass resource.options to scope...

    def resources(*resources, &block)
    ...
      with_scope_level(:member) do
        scope(':id') do
          scope(resource.options) do
            get    :show if resource.actions.include?(:show)
            put    :update if resource.actions.include?(:update)
            delete :destroy if resource.actions.include?(:destroy)
            get    :edit, :as => resource.singular if resource.actions.include?(:edit)
          end
        end
    ...
    end
    

    but member is not passing.

    def member
      unless @scope[:scope_level] == :resources
        raise ArgumentError, "can't use member outside resources scope"
      end
    
      with_scope_level(:member) do
        scope(':id', :name_prefix => parent_resource.member_name, :as => "") do
          yield
        end
      end
    end
    

    Oddly, some options like 'as' works nice.

    April 26th, 2010 @ 03:34 AM

  2. Daniel Libanori
    Daniel Libanori
    • Tag changed from rails3 routes to rails3, routes

    April 26th, 2010 @ 03:58 AM

  3. Daniel Libanori
    Daniel Libanori

    This patch can help to solve bug #3765 Missing shallow routes in new router DSL too. It uses a better way to create default CRUD actions.

    April 26th, 2010 @ 08:11 AM

  4. Daniel Libanori
  5. Steven Ringo
    Steven Ringo
    • Assigned user set to Ryan Bigg

    Patch applies cleanly and associated tests pass.

    +1

    April 27th, 2010 @ 11:02 AM

  6. Andrew White
    Andrew White
    • State changed from new to resolved
    • Assigned user changed from Ryan Bigg to Andrew White
    • Importance changed from to Low

    This appears to be resolved by the patch applied from #3765 Missing shallow routes in new router DSL. Please comment here if you think it doesn't.

    June 28th, 2010 @ 10:13 AM