The previous "[Ruby on Rails] and I learned hello World" mentioned that the route corresponding to the file is CONFIG/ROUTES.RB
In fact, we just added a line of code:
Resources:p OSTs
However, this code has multiple default routes, which can be viewed through rake routes, as follows:
[Email protected]:/home/ywt/ror_tests/blog# rake routes Prefix Verb URI Pattern controller#action Posts get /posts (.: format) posts#index POST /posts (.: format) posts#create new_post GET / Posts/new (.: format) posts#newedit_post get /posts/:id/edit (.: format) Posts#edit post get / Posts/:id (.: format) posts#show PATCH /posts/:id (.: format) posts#update PUT / Posts/:id (.: format) posts#update delete/posts/:id (.: format) Posts#destroy
which
Index corresponds to a list of multiple objects
New New page for a single object
Edit the editing page for a single object
Show a realistic page for a single object
And, Create/update/destroy is not a view (page) file, processing the actual data created, updated, delete operations.
So for a Post object, we have 7 action, four of which have a view file.
Modify the APP/CONTROLLERS/POSTS_CONTROLLER.RB as follows:
Class Postscontroller < Applicationcontroller def index end def new end def create end def edit end def update end def show end def destroy EndEnd
Added Files App/views/new.html.erb, App/views/edit.html.erb, App/views/show.html.erb, respectively, corresponding to the new action, edit action, show action.
This chapter lays the groundwork for subsequent work.
[Ruby on Rails] and I learned route map