0

好的,所以我的 routes.rb 文件中有这个循环

[:animals, :humans].each do |app|
  resources app, controller => "mammals", type: app.to_s do
    member do
      post :deny
    end

    collection do
      get :wait, :state => 'wait', :action => 'index'
    end
  end
end

但我得到这个错误错误的参数数量(0 代表 1)

/Users/trace/.rvm/gems/ruby-1.9.3-p327@sss/gems/actionpack-3.1.10/lib/action_dispatch/routing/mapper.rb:651:in `controller'
/Users/trace/Sites/sss/config/routes.rb:31:in `block (2 levels) in <top (required)>'
/Users/trace/Sites/sss/config/routes.rb:30:in `each'

但我在 routes.rb 的其他部分使用循环,一切都很好

关于正在发生的事情的任何想法......可能是语法错误

4

2 回答 2

3

这看起来很可疑:

resources app, controller => "mammals", type: app.to_s do

怎么样:

resources app, controller: "mammals", type: app.to_s do
于 2013-01-10T23:12:42.550 回答
2

您缺少控制器上的冒号。

  resources app, controller => "mammals", type: app.to_s do

应该

  resources app, :controller => "mammals", type: app.to_s do
于 2013-01-10T23:12:46.677 回答