[英]What is the manually typed equivalent of resources in rails routes.rb?
Suppose rails new myapp && cd myapp && rails g scaffold Teacher
假设
rails new myapp && cd myapp && rails g scaffold Teacher
routes.rb
contains resources :teachers
routes.rb
包含resources :teachers
What is the manually typed equivalent of this single line in routes.rb
? 在
routes.rb
手动键入的单行等效项是什么? (the reason I ask is because I would like to keep most, but edit some of the routes) (我问的原因是因为我想保留最多的路线,但要编辑一些路线)
The only two things a user could need is to view some data ('get') or delete a record ('destroy') or insert a new record ('create')
用户可能需要做的仅有两件事是查看某些数据(“获取”)或删除记录(“销毁”)或插入新记录(“创建”)。
This scenario is supported: 支持此方案:
resources :teachers, only: [:show, :destroy, :create]
As for the "manual" routes, you could express, say, the :show
route like this: 至于“手动”路由,您可以这样表达
:show
路由:
get '/teachers/:id', to: 'teachers#show'
The full equivalents are as follows: 完整的等效项如下:
get '/teachers' => 'teachers#index'
get '/teachers/:id' => 'teachers#show'
get '/teachers/new' => 'teachers#new'
post '/teachers' => 'teachers#create'
get '/teachers/:id/edit' => 'teachers#edit'
put '/teachers' => 'teachers#update'
delete '/teachers' => 'teachers#destroy'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.