如果我将其放入route.rb get '/products/:id', to: 'products#edit'
,当网址格式为/patients/:id
时,应调用编辑操作这是否意味着它会被重定向到编辑页面?我试过这个并没有重定向。
这是我的佣金路线输出
admin GET /admin(.:format) {:action=>"index", :controller=>"admin"}
GET /products/:id(.:format) {:controller=>"products", :action=>"edit"}
login GET /login(.:format) {:action=>"new", :controller=>"sessions"}
POST /login(.:format) {:action=>"create", :controller=>"sessions"}
logout DELETE /logout(.:format) {:action=>"destroy", :controller=>"sessions"}
users GET (/:locale)/users(.:format) {:action=>"index", :controller=>"users"}
POST (/:locale)/users(.:format) {:action=>"create", :controller=>"users"}
new_user GET (/:locale)/users/new(.:format) {:action=>"new", :controller=>"users"}
edit_user GET (/:locale)/users/:id/edit(.:format) {:action=>"edit", :controller=>"users"}
user GET (/:locale)/users/:id(.:format) {:action=>"show", :controller=>"users"}
PUT (/:locale)/users/:id(.:format) {:action=>"update", :controller=>"users"}
DELETE (/:locale)/users/:id(.:format) {:action=>"destroy", :controller=>"users"}
orders GET (/:locale)/orders(.:format) {:action=>"index", :controller=>"orders"}
POST (/:locale)/orders(.:format) {:action=>"create", :controller=>"orders"}
new_order GET (/:locale)/orders/new(.:format) {:action=>"new", :controller=>"orders"}
edit_order GET (/:locale)/orders/:id/edit(.:format) {:action=>"edit", :controller=>"orders"}
order GET (/:locale)/orders/:id(.:format) {:action=>"show", :controller=>"orders"}
PUT (/:locale)/orders/:id(.:format) {:action=>"update", :controller=>"orders"}
DELETE (/:locale)/orders/:id(.:format) {:action=>"destroy", :controller=>"orders"}
line_items GET (/:locale)/line_items(.:format) {:action=>"index", :controller=>"line_items"}
POST (/:locale)/line_items(.:format) {:action=>"create", :controller=>"line_items"}
new_line_item GET (/:locale)/line_items/new(.:format) {:action=>"new", :controller=>"line_items"}
edit_line_item GET (/:locale)/line_items/:id/edit(.:format) {:action=>"edit", :controller=>"line_items"}
line_item GET (/:locale)/line_items/:id(.:format) {:action=>"show", :controller=>"line_items"}
PUT (/:locale)/line_items/:id(.:format) {:action=>"update", :controller=>"line_items"}
DELETE (/:locale)/line_items/:id(.:format) {:action=>"destroy", :controller=>"line_items"}
carts GET (/:locale)/carts(.:format) {:action=>"index", :controller=>"carts"}
POST (/:locale)/carts(.:format) {:action=>"create", :controller=>"carts"}
new_cart GET (/:locale)/carts/new(.:format) {:action=>"new", :controller=>"carts"}
edit_cart GET (/:locale)/carts/:id/edit(.:format) {:action=>"edit", :controller=>"carts"}
cart GET (/:locale)/carts/:id(.:format) {:action=>"show", :controller=>"carts"}
PUT (/:locale)/carts/:id(.:format) {:action=>"update", :controller=>"carts"}
DELETE (/:locale)/carts/:id(.:format) {:action=>"destroy", :controller=>"carts"}
who_bought_product GET (/:locale)/products/:id/who_bought(.:format) {:action=>"who_bought", :controller=>"products"}
products GET (/:locale)/products(.:format) {:action=>"index", :controller=>"products"}
POST (/:locale)/products(.:format) {:action=>"create", :controller=>"products"}
new_product GET (/:locale)/products/new(.:format) {:action=>"new", :controller=>"products"}
edit_product GET (/:locale)/products/:id/edit(.:format) {:action=>"edit", :controller=>"products"}
product GET (/:locale)/products/:id(.:format) {:action=>"show", :controller=>"products"}
PUT (/:locale)/products/:id(.:format) {:action=>"update", :controller=>"products"}
DELETE (/:locale)/products/:id(.:format) {:action=>"destroy", :controller=>"products"}
store /(:locale)(.:format) {:controller=>"store", :action=>"index"}
答案 0 :(得分:0)
您到达那里的路线没有重定向,它将网址/patients/:id
映射到edit
的{{1}}操作。
当用户点击PatientsController
网址时,系统会调用/patients/id
操作。默认情况下,它会尝试呈现与操作同名的视图。
如果要渲染编辑页面,请在名为edit
的{{1}}文件夹中创建一个视图。
(顺便说一下,/app/views/patients
路由通常用于edit.html.erb
操作。)