Suppose rails new myapp && cd myapp && rails g scaffold Teacher
routes.rb
contains resources :teachers
What is the manually typed equivalent of this single line in 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:
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'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.