【发布时间】:2012-03-23 02:10:35
【问题描述】:
我的 routes.rb 中有 rails 资源。我在控制器中创建了方法:
def test_action
end
并在 routes.rb 中添加了一行:
Test2::Application.routes.draw do
resources :todos
resources :docs
match "/todos/test_action" => "todos#test_action"
end
但是当我尝试获取 ulr http://localhost:3000/todos/test_action/ 时,我收到了错误消息:
illegal ObjectId format: test_action
为什么以及如何解决它?
【问题讨论】:
-
你把你的路线放在哪里了?据我记得,较早的路线优先于匹配后者。
-
你能在
match "/todos/test_action"周围显示代码吗? -
我更新了我的问题并包含了整个 routes.rb
标签: ruby-on-rails