English 中文(简体)
具有多个参数的航道
原标题:rake routes with multiple parameters

这里是尿素之一的游轮输出。

bug_info  /bugs/:pr/:scope/info(.:format)       {:controller=>"bugs", :action=>"info"}

在耳目中,如果一叫bug_info_path(:pr=>1:cop=>2),则观点给我一个错误说:

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

我在这里做的是错做的。

match  bugs/:pr/:scope/info  =>  bugs#info , :as=>:bug_info
最佳回答

Very weird. 我通过生产一部新铁路,用你身上的 st子进行检测,似乎进行罚款。 这就是我所说的话。 (铁路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

b)

class BugsController < ApplicationController
  def test
  end

  def info
  end
end

app/view/test

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

页: 1

<%= params %>

I browse to /test 我这样做:

/bugs/1/2/info

I browse to /bugs/1/2/info/code>

{“控制器”=> “bugs”、“action”=>“info”、“pr”=>”1”、“cop”=>”2}

或许你们也可以尝试用最低限度的铁路,然后在一间断裂之前添加东西。

问题回答

暂无回答




相关问题
Remove ActiveRecord in Rails 3

Now that Rails 3 beta is out, I thought I d have a look at rewriting an app I have just started work on in Rails 3 beta, both to get a feel for it and get a bit of a head-start. The app uses MongoDB ...

When will you upgrade your app to Rails 3? [closed]

Now that the Rails 3 beta is here, let s take a little straw poll. Please tell us briefly what your application does and when you will upgrade it to Rails 3. Or, if you re not planning on upgrading ...

Bundler isn t loading gems

I have been having a problem with using Bundler and being able to access my gems without having to require them somewhere, as config.gem used to do that for me (as far as I know). In my Rails 3 app, I ...

bypass attr_accessible/protected in rails

I have a model that, when it instantiates an object, also creates another object with the same user id. class Foo > ActiveRecord::Base after_create: create_bar private def create_bar Bar....

concat two fields activerecord

I m so used to oracle where you can simply concat(field1, , field2) but if I m using activerecord to find the field1 and field2, and I need a space in between, how do I accomplish this? Cheers ...