黄瓜路由问题 [英] Routing problem with cucumber

查看:93
本文介绍了黄瓜路由问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用rails 3和黄瓜,除了这个小问题,一切都进行得很好。

  edit autompage 
没有路由匹配{:controller =>automobiles,:action =>edit}(ActionController :: RoutingError)
pre>

现在路径在paths.rb中设置为edit_automobile_path



,在routes.rb中汽车作为资源,我脚手架它



所以请告诉我什么我失踪,清楚的路线被定义和匹配,因为我跑了耙路线,看到了路线。



请指出正确的方向

解决方案

code> features / support / paths.rb 这样的路径文件,指定您需要传递 edit_automobile_path 的唯一资源id,



在您的rake路线中,它将会像 automobiles /:id / edit



因此您需要 edit_automobile_path(:id



在黄瓜做这个假设你有像

 假设我有一辆汽车
我在编辑汽车'page

在您给定的步骤中,def声明一个变量 @automobile = Automobile。 create()



然后在您的paths.rb文件中

  when / edit automobile page / 
edit_automobile_path @automobile
...


I am working with rails 3 and cucumber, all is going well except for this little problem

Given I am on the "edit automobile" page
  No route matches {:controller=>"automobiles", :action=>"edit"} (ActionController::RoutingError)

Now the path is set in paths.rb as edit_automobile_path

and in the routes.rb I have automobiles as a resource, I scaffolded it

so please tell me what I am missing, clearly the route is defined and matches, because I ran rake routes and saw the route.

please point me in the right direction

解决方案

In your features/support/paths.rb file for a path like this that specifies a unique resource you need to pass your edit_automobile_path an id,

in your rake routes it will look like automobiles/:id/edit

so you need to have edit_automobile_path(:id)

In order to do this in cucumber assume you have something like

Given I have an automobile
And I am on the 'edit automobile' page

In your given step def declare a variable @automobile = Automobile.create()

And then in your paths.rb file

when /edit automobile page/
  edit_automobile_path @automobile
...

这篇关于黄瓜路由问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆