This project is archived and is in readonly mode.

#4126 ✓invalid
epochwolf

Routes: match ignores :conditions.

Reported by epochwolf | March 7th, 2010 @ 09:09 PM

On a clean rails 3.0.0-beta application the routing command match ignores the :conditions hash if it is given. (Does not affect resource(s))

I used the following code in a cleanly build application to test this. (Needed to remove protect_from_forgery from ApplicationController)

Routes

    root :to => "home#index"
    match "get", :to => "home#get", :conditions => {:method => :get}
    match "post", :to => "home#post", :conditions => {:method => :post}

HomeController

    class HomeController < ApplicationController
      def index
        render :text => "index\n"
      end
  
      def get
        if request.get?
          render :text => "get\n"
        else
          render :text => "not_get\n"
        end
      end
  
      def post
        if request.get?
          render :text => "get\n"
        else
          render :text => "not_get\n"
        end
      end
    end

Tests

    user@host:~$ curl http://localhost:3001/get
    get
    user@host:~$ curl -F 'field=1' localhost:3001/get
    not_get
    user@host:~$ curl http://localhost:3001/post
    get
    user@host:~$ curl -F 'field=1' localhost:3001/post
    not_get

Comments and changes to this ticket

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>

People watching this ticket

Tags

Pages