This project is archived and is in readonly mode.

#2700 ✓wontfix
trevor

[PATCH] in routes.rb :conditions => {:method => :any} gives error

Reported by trevor | May 23rd, 2009 @ 06:18 PM | in 2.x

in routes.rb -

ActionController::Routing::Routes.draw do |map|
  map.good 'good', :controller => 'good', :conditions => {:method => :get}

map.bad 'bad', :controller => 'bad', :conditions => {:method => :any}




map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' end

rake routes returns

good GET /good                              {:controller=>"good", :action=>"index"}

     /:controller/:action/:id
     /:controller/:action/:id(.:format)</code>



when bad is uncommented

rake aborted!
Invalid HTTP method specified in route conditions: {:method=>:any}

Comments and changes to this ticket

  • qoobaa

    qoobaa June 29th, 2009 @ 08:35 PM

    Can't you just use:

    ActionController::Routing::Routes.draw do |map|
      map.good 'good', :controller => 'good', :conditions => {:method => :get}
      map.bad 'bad', :controller => 'bad'
      map.connect ':controller/:action/:id'
      map.connect ':controller/:action/:id.:format'
    end
    

    Does it make any sense to add a condition that matches every case?

  • trevor

    trevor June 29th, 2009 @ 08:46 PM

    the documentation states "Takes a hash of #{action} => #{method}, where method is :get/:post/:put/:delete, an array of any of the previous, or :any if the method does not matter."

    i'm expecting consistent behavior, one way or the other.

    % grep -R ':any' r*
    resources.rb:    #   an array of any of the previous, or <tt>:any</tt> if the method does not matter.
    resources.rb:    #   map.resources :messages, :new => { :new => :any, :preview => :post }
    resources.rb:          options[:conditions][:method] = method unless method == :any
    routing/route.rb:          "%-6s %-40s %s" % [(conditions[:method] || :any).to_s.upcase, segs, requirements.inspect]
    routing.rb:  #   <tt>:get</tt>, <tt>:put</tt>, <tt>:delete</tt> and <tt>:any</tt>. The default value is <tt>:any</tt>,
    routing.rb:  #   <tt>:any</tt> means that any method can access the route.
    
  • Frankie Roberto

    Frankie Roberto July 2nd, 2009 @ 01:53 PM

    This seems does seem to be broken.

    Works for resources (:collection => {:test => :any}) but not for named paths.

  • anupom syam

    anupom syam July 14th, 2009 @ 06:47 PM

    • Tag set to patch, tested

    i think it's broken. i am adding a patch along with this ticket (with tests).

  • anupom syam

    anupom syam July 19th, 2009 @ 07:13 PM

    • Title changed from “in routes.rb :conditions => {:method => :any} gives error” to “[PATCH] in routes.rb :conditions => {:method => :any} gives error”
  • CancelProfileIsBroken

    CancelProfileIsBroken August 7th, 2009 @ 02:31 PM

    • Tag changed from patch, tested to bugmash, patch, tested
  • qmx

    qmx August 8th, 2009 @ 02:19 AM

    +1

    Apply cleanly to current stable.

  • pjammer

    pjammer August 8th, 2009 @ 03:10 AM

    +1 I verified this patched worked for me in a mini app, as well as the tests passed.

  • Derander

    Derander August 9th, 2009 @ 09:18 PM

    +1 verified. Applies cleanly to current stable & master.

    Tests pass for stable, and two tests fail on master. I do not believe they're related -- they're dealing w/ the textilize method.

  • José Valim

    José Valim August 9th, 2009 @ 10:58 PM

    • State changed from “new” to “wontfix”
    • Tag changed from bugmash, patch, tested to patch, tested

    As Jakub pointed, you can already do that. We would just add more code to maintain.

  • freerobby

    freerobby January 4th, 2010 @ 10:31 PM

    If you need a quick substitute, passing in nil in place of :any works as follows:
    :conditions => {:method => nil}

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