This project is archived and is in readonly mode.

#4475 ✓resolved
Daniel Libanori

Resources is not passing all options to yield

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

Comments and changes to this ticket

  • Daniel Libanori

    Daniel Libanori April 26th, 2010 @ 03:34 AM

    • 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.

  • Daniel Libanori

    Daniel Libanori April 26th, 2010 @ 03:58 AM

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

    Daniel Libanori April 26th, 2010 @ 08:11 AM

    This patch can help to solve bug #3765 too. It uses a better way to create default CRUD actions.

  • Daniel Libanori
  • Steven Ringo

    Steven Ringo April 27th, 2010 @ 11:02 AM

    • Assigned user set to “Ryan Bigg”

    Patch applies cleanly and associated tests pass.

    +1

  • Andrew White

    Andrew White June 28th, 2010 @ 10:13 AM

    • 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. Please comment here if you think it doesn't.

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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Tags

Pages