Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 尝试使链接看起来像按钮时的路由_Ruby On Rails_Ruby On Rails 3_Ruby On Rails 3.2 - Fatal编程技术网

Ruby on rails 尝试使链接看起来像按钮时的路由

Ruby on rails 尝试使链接看起来像按钮时的路由,ruby-on-rails,ruby-on-rails-3,ruby-on-rails-3.2,Ruby On Rails,Ruby On Rails 3,Ruby On Rails 3.2,我有我的链接,可以编辑这样的品牌: <%= link_to 'Edit', :action => 'edit', :id => brand %> http://localhost:3000/admin/brand/edit.1 但是,生成的url如下所示: <%= link_to 'Edit', :action => 'edit', :id => brand %> http://localhost:3000/admin/brand/edit.

我有我的链接,可以编辑这样的品牌:

<%= link_to 'Edit', :action => 'edit', :id => brand %>
http://localhost:3000/admin/brand/edit.1
但是,生成的url如下所示:

<%= link_to 'Edit', :action => 'edit', :id => brand %>
http://localhost:3000/admin/brand/edit.1
它应该在哪里

http://localhost:3000/admin/brand/edit/1
品牌编辑的
rake路由结果

admin_brand_edit GET  /admin/brand/edit(.:format)        admin/brand#edit
admin_brand_update POST /admin/brand/update(.:format)    admin/brand#update
routes.rb

get 'admin/brand/edit'

你能分享一下你的
路线吗。rb
请。您似乎有两个不同的路径用于
管理/品牌#编辑
。顺便说一句,
按钮_to
将默认为POST操作,这就是为什么您需要使用方法get-@graemeclean覆盖它是的,我知道。我发布了
routes.rb
并更新了
rake routes
。我删除了要编辑的重复路由,我只是尝试匹配格式,所以它返回了所需的操作。很抱歉,我现在有点困惑。你的问题解决了没有?我希望您的路线更像
get'admin/brand/:id/edit'
,因为您想要编辑一个特定的实例。当我使用链接时,路线是
admin/brand/edit/id
。这个问题没有解决。