开发者

rake routes with multiple parameters

Here is the rake routes output for one of the urls

bug_info  /bugs/:pr/:scope/info(.:format)       {:controller=>"bugs", :action=&g开发者_StackOverflow社区t;"info"}

Inside the erb view if i call bug_info_path(:pr=>1,:scope=>2), the view gives me an error saying

No route matches {:scope=>"2", :action=>"info", :controller=>"bugs", :pr=>"1"}

What am I doing wrong here

match 'bugs/:pr/:scope/info' => 'bugs#info', :as=>:bug_info


Very weird. I tested by generating a new rails app and populated with your stuff and it seems to work fine. Here is what I got. (This is with Rails 3.0.7).

config/route.rb

Railstest::Application.routes.draw do
  match 'test' => 'bugs#test', :as=>:bug_test
  match 'bugs/:pr/:scope/info' => 'bugs#info', :as=>:bug_info
end

app/controllers/bugs_controller.rb

class BugsController < ApplicationController
  def test
  end

  def info
  end
end

app/views/bugs/test.erb

<%= bug_info_path(:pr=>1,:scope=>2) %>

app/views/bugs/info.erb

<%= params %>

When I browse to /test I get this:

/bugs/1/2/info

When I browse to /bugs/1/2/info

{"controller"=>"bugs", "action"=>"info", "pr"=>"1", "scope"=>"2"}

Maybe you could try with a minimal rails app too and then add things until i breaks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜