views:

14

answers:

0

I have the following route in my Rails 3 app.

post 'games/:id/:task/:card_id' => 'games#perform', :as => :perform

...which allows, obviously, such requests as button_to("Foo", {card_id=>2, :action=>:perform, :task=>"foo"}), mapping to the URL /games/1/foo/2.

I'd like to restrict the set of tasks the route matches. The Rails API docs indicate that "Constraints can include the ‘ignorecase’ and ‘extended syntax’ regular expression modifiers". However, the following works as expected:

post 'games/:id/:task/:card_id' => 'games#perform', :as => :perform, :constraints => {:task => /(foo|bar)/}

But the following doesn't:

post 'games/:id/:task/:card_id' => 'games#perform', :as => :perform, :constraints => {:task => /(foo|
                                                                                                 bar)/x}

In the latter case, the button_to link above produces the URL: /games/perform?card_id=2&task=foo.

Is this a bug, or am I doing something wrong?