我已經有這個在我的路線文件:路線錯誤 - Ruby on Rails的
namespace :api do
root :to => 'graphs#index' #default page when accessing /admin
resources :graphs, :defaults => { :format => 'json' }
match ':graphs/:id(/:method)'
end
但是當我嘗試打開:
mydomain.com/api
或
mydomain.com/api/graphs/
我得到了以下錯誤:
2011-07-06T23:12:06+00:00 app[web.1]: /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/routing/mapper.rb:171:in `default_controller_and_action': missing :action (ArgumentError)
2011-07-06T23:12:06+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/routing/mapper.rb:72:in `normalize_options!'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/routing/mapper.rb:55:in `initialize'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/routing/mapper.rb:272:in `new'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/routing/mapper.rb:272:in `match'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/routing/mapper.rb:1173:in `match'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/routing/mapper.rb:1360:in `match'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/config/routes.rb:84:in `block (2 levels) in <top (required)>'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/routing/mapper.rb:624:in `block in namespace'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/routing/mapper.rb:546:in `scope'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/routing/mapper.rb:624:in `namespace'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/routing/mapper.rb:1119:in `namespace'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/config/routes.rb:80:in `block in <top (required)>'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/routing/route_set.rb:233:in `instance_exec'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/routing/route_set.rb:233:in `draw'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/config/routes.rb:1:in `<top (required)>'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:235:in `load'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:235:in `block in load'
2011-07-06T23:12:06+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:227:in `load_dependency'
2011-07-06T23:12:06+00:00 app[web.1]: from <internal:lib/rubygems/custom_require>:29:in `require'
2011-07-06T23:12:06+00:00 heroku[web.1]: Process exited
2011-07-06T23:12:07+00:00 heroku[web.1]: State changed from starting to crashed
你運行'耙routes'查看路線圖? –