[RUBY] [rails] How to configure routing in resources

Set up routing in resources

Routing can also be set individually. However, since the seven basic actions in rails are often used during development, It is not efficient to set it each time. In such a case, if you use the resources method, the routing will be set automatically just by writing one line.

Rails.application.routes.draw do
  resources :blogs
end

Check with the rails routes command.

$ rails routes

Make sure all urls are set.

$ rails routes
                   Prefix Verb   URI Pattern                                                                              Controller#Action
                    blogs GET    /blogs(.:format)                                                                         blogs#index
                          POST   /blogs(.:format)                                                                         blogs#create
                 new_blog GET    /blogs/new(.:format)                                                                     blogs#new
                edit_blog GET    /blogs/:id/edit(.:format)                                                                blogs#edit
                     blog GET    /blogs/:id(.:format)                                                                     blogs#show
                          PATCH  /blogs/:id(.:format)                                                                     blogs#update
                          PUT    /blogs/:id(.:format)                                                                     blogs#update
                          DELETE /blogs/:id(.:format)                                                                     blogs#destroy
       rails_service_blob GET    /rails/active_storage/blobs/:signed_id/*filename(.:format)                               active_storage/blobs#show
rails_blob_representation GET    /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
       rails_disk_service GET    /rails/active_storage/disk/:encoded_key/*filename(.:format)                              active_storage/disk#show
update_rails_disk_service PUT    /rails/active_storage/disk/:encoded_token(.:format)                                      active_storage/disk#update
     rails_direct_uploads POST   /rails/active_storage/direct_uploads(.:format)                                           active_storage/direct_uploads#create

Recommended Posts

[rails] How to configure routing in resources
How to write Rails routing
[Rails] How to write in Japanese
How to introduce jQuery in Rails 6
How to install Swiper in Rails
How to implement search functionality in Rails
How to change app name in rails
How to insert a video in Rails
How to use MySQL in Rails tutorial
How to implement ranking functionality in Rails
How to use credentials.yml.enc introduced in Rails 5.2
How to write Rails
How to uninstall Rails
[Rails] How to use select boxes in Ransack
How to translate Rails into Japanese in general
How to prevent direct URL typing in Rails
How to conditionally add html.erb class in Rails
How to implement a like feature in Rails
How to easily create a pull-down in Rails
How to use JQuery in js.erb of Rails6
[Ruby on Rails] How to install Bootstrap in Rails
How to make a follow function in Rails
[Rails] How to use PostgreSQL in Vagrant environment
How to check Rails commands in the terminal
[rails] How to post images
How to set the display time to Japan time in Rails
How to implement guest login in 5 minutes in rails portfolio
[Rails] How to use enum
[Rails] How to install devise
[Rails] How to use enum
How to read rails routes
[Refactoring] How to write routing
[Ruby On Rails] How to reset DB in Heroku
How to use rails join
[How to insert a video in haml with Rails]
How to write a date comparison search in Rails
How to terminate rails server
How to write Rails validation
How to write Rails seed
[Rails] How to use validation
How to query Array in jsonb with Rails + postgres
[Rails 6] How to set a background image in Rails [CSS]
[Rails] How to disable turbolinks
[Rails] How to use authenticate_user!
[Rails] How to use "kaminari"
[Rails] How to implement scraping
[Rails] How to make seed
[Rails] How to load JavaScript in a specific view
[Rails] How to install simple_calendar
[Rails] How to install reCAPTCHA
[Rails] How to display an image in the view
[Rails] How to use Scope
[Rails / Routing] Deepen on how to set Prefix and URI to your favorite values and resources
[Rails] How to define macros in Rspec and standardize processing
How to deploy jQuery in your Rails app using Webpacker
How to display a graph in Ruby on Rails (LazyHighChart)
Super easy in 2 steps! How to install devise! !! (rails 5 version)
[Rails5] japanMap link How to write parameters in js.erb file
[Rails] How to display information stored in the database in view
[Rails] How to write user_id (foreign key) in strong parameter
[Rails] How to use gem "devise"