views:

20

answers:

2

I've a controller :platform here.

I'm trying to do something like:

/:platform_name/ to redirect to its show, with the parameter. Here is what I've got:

map.resource :platform,
               :as => ':platform_name',
               :platform_name => /pc|ps2|ps3|wii|ds|psp|xbox-360/

It's working fine. I've other neasted resources to it, and all them are accessing. But. The problem is, I've only those platform names, but when it doesnt fine another route, it aways fall on this. if I try /whatever/, it will look for the *platform_name => whatever*.

I was expecting it to fall into the map.connect ':controller/:action/:id' rule.

When I did *:platform_name => /pc|ps2|ps3|wii|ds|psp|xbox-360/*, wasnt expected that this rule only apply when the regular expression is fit?

how could i restrict this?

A: 

Try changing:

/pc|ps2|ps3|wii|ds|psp|xbox-360/

to

/^(pc|ps2|ps3|wii|ds|psp|xbox-360)$/
jonnii
still the same, its not restricting the platform_names to the ones in the regexp
Tiago
here, trying to access /password_recover/edit (expected :controller => :password_recovery, :action => :edit). Sends me to => Processing PlatformsController#edit (for 127.0.0.1 at 2010-03-10 11:56:06) [GET] Parameters: {"platform_name"=>"password_recover", "action"=>"edit", "locale"=>"pt", "controller"=>"platforms"}
Tiago
Can you post your entire routes.rb pls.
jonnii
A: 

Maybe you could try

:requirements => { :platform_name => /pc|ps2|ps3|wii|ds|psp|xbox-360/ }

or

:conditions => { ... }

ActionController::Resources#resources

LWille