Ruby on rails 在轨道路线上循环
好的,我在routes.rb文件中有这个循环Ruby on rails 在轨道路线上循环,ruby-on-rails,ruby,ruby-on-rails-3,routes,Ruby On Rails,Ruby,Ruby On Rails 3,Routes,好的,我在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 en
[: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层)in'
/Users/trace/Sites/sss/config/routes.rb:30:在'each'中
但是我在routes.rb的其他部分使用循环,一切都很好
有什么想法吗…可能是语法错误这看起来很可疑:
resources应用程序,controller=>“哺乳动物”,类型:app.to\u s do
那么:
resources app, controller: "mammals", type: app.to_s do
这看起来很可疑:
resources应用程序,controller=>“哺乳动物”,类型:app.to\u s do
那么:
resources app, controller: "mammals", type: app.to_s do
控制器上缺少冒号
resources app, controller => "mammals", type: app.to_s do
应该是
resources app, :controller => "mammals", type: app.to_s do
控制器上缺少冒号
resources app, controller => "mammals", type: app.to_s do
应该是
resources app, :controller => "mammals", type: app.to_s do