Rails 3 路由:控制器规范与成员路由不匹配
我正在尝试为成员控制器操作编写一个规范,该操作假设指向“/admin/projects/:id/some_action”,routes.rb 文件具有以下内容:
namespace :admin do
resources :projects do
member do
get :some_action
end
end
end
因此,当我运行 $ rake paths 时,我得到了正确的 url /admin/projects/:id/some_action,但在控制器规范中我遇到了一个该死的错误。
describe Admin::ProjectsController do
it "should get the action" do
project = mock_model(:project, :id => 1)
get :some_action, {:id => project.id}
end
end
结果总是一样的:
Failure/Error: get :some_action, {:id => 1}
ActionController::RoutingError:
No route matches {:id=>1, :controller=>"admin/projects", :action=>"some_action"}
有人遇到过这种问题吗?有什么建议可以解决吗?
我真的很感谢任何帮助,谢谢!
I'm trying to write a spec to a member controller action that suppose to points to "/admin/projects/:id/some_action", the routes.rb file has the following content:
namespace :admin do
resources :projects do
member do
get :some_action
end
end
end
So, when I run $ rake routes I got the right url /admin/projects/:id/some_action, but in the controller spec I got a dammed error.
describe Admin::ProjectsController do
it "should get the action" do
project = mock_model(:project, :id => 1)
get :some_action, {:id => project.id}
end
end
The result is always the same:
Failure/Error: get :some_action, {:id => 1}
ActionController::RoutingError:
No route matches {:id=>1, :controller=>"admin/projects", :action=>"some_action"}
Someone pass through this kind of problem? Any suggestion to solve it?
I really appreciate any help, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论