Ruby on rails rails 3,我可以创建包含url参数的路由吗?

Ruby on rails rails 3,我可以创建包含url参数的路由吗?,ruby-on-rails,url,routes,Ruby On Rails,Url,Routes,我们有 mobilemethod接受将其置于“查找模式”的url参数?find=true 是否有方法添加一个路由/f/:id,该路由将使用url参数调用mobilemethod?find=true (或者,有没有办法让一个方法知道最初调用了哪个路由,在这种情况下,我可以简单地将/m和/f映射到同一个方法,然后在方法内部检查url上调用了哪个路由) 我试过了 match '/m/:id' => 'foo#mobilemethod' 及 但是获得“未知操作”错误这应该可以做到这一点: mat

我们有

mobilemethod接受将其置于“查找模式”的url参数
?find=true

是否有方法添加一个路由
/f/:id
,该路由将使用url参数调用mobilemethod
?find=true

(或者,有没有办法让一个方法知道最初调用了哪个路由,在这种情况下,我可以简单地将/m和/f映射到同一个方法,然后在方法内部检查url上调用了哪个路由)

我试过了

match '/m/:id' => 'foo#mobilemethod'


但是获得“未知操作”错误

这应该可以做到这一点:

match '/f/:id' => 'foo#mobilemethod/:id?find=true'

这应该可以做到这一点:

match '/f/:id' => 'foo#mobilemethod/:id?find=true'
显示参数id和查找结果

或者您想要一个默认值

match '/f/:id' => 'foo#mobilemethod'
                    ^       ^
             controller    action


match '/f/:id/find/:find' => 'foo#mobile_method'
显示参数id和查找结果

或者您想要一个默认值

match '/f/:id' => 'foo#mobilemethod'
                    ^       ^
             controller    action


match '/f/:id/find/:find' => 'foo#mobile_method'

太好了,我想rails会有一些很酷、简单的方法来做到这一点!太好了,我想rails会有一些很酷、简单的方法来做到这一点!
match '/m/:id' => 'foo#mobilemethod', :defaults => { :find => true }