URL設計を考える際にroutesファイルの書き方に迷うことがあったので、新規でWebアプリを作成し確かめてみました。
% rails new book_admin
デフォルトのroutes.rbの状態は以下のとおり。
Rails.application.routes.draw do # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Defines the root path route ("/") # root "articles#index" end
すでに30のルートが用意されています。
% rails routes -E --[ Route 1 ]-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | turbo_recede_historical_location Verb | GET URI | /recede_historical_location(.:format) Controller#Action | turbo/native/navigation#recede --[ Route 2 ]-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | turbo_resume_historical_location Verb | GET URI | /resume_historical_location(.:format) Controller#Action | turbo/native/navigation#resume --[ Route 3 ]-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | turbo_refresh_historical_location Verb | GET URI | /refresh_historical_location(.:format) Controller#Action | turbo/native/navigation#refresh --[ Route 4 ]-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_postmark_inbound_emails Verb | POST URI | /rails/action_mailbox/postmark/inbound_emails(.:format) Controller#Action | action_mailbox/ingresses/postmark/inbound_emails#create --[ Route 5 ]-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_relay_inbound_emails Verb | POST URI | /rails/action_mailbox/relay/inbound_emails(.:format) Controller#Action | action_mailbox/ingresses/relay/inbound_emails#create --[ Route 6 ]-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_sendgrid_inbound_emails Verb | POST URI | /rails/action_mailbox/sendgrid/inbound_emails(.:format) Controller#Action | action_mailbox/ingresses/sendgrid/inbound_emails#create --[ Route 7 ]-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_mandrill_inbound_health_check Verb | GET URI | /rails/action_mailbox/mandrill/inbound_emails(.:format) Controller#Action | action_mailbox/ingresses/mandrill/inbound_emails#health_check --[ Route 8 ]-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_mandrill_inbound_emails Verb | POST URI | /rails/action_mailbox/mandrill/inbound_emails(.:format) Controller#Action | action_mailbox/ingresses/mandrill/inbound_emails#create --[ Route 9 ]-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_mailgun_inbound_emails Verb | POST URI | /rails/action_mailbox/mailgun/inbound_emails/mime(.:format) Controller#Action | action_mailbox/ingresses/mailgun/inbound_emails#create --[ Route 10 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_conductor_inbound_emails Verb | GET URI | /rails/conductor/action_mailbox/inbound_emails(.:format) Controller#Action | rails/conductor/action_mailbox/inbound_emails#index --[ Route 11 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | Verb | POST URI | /rails/conductor/action_mailbox/inbound_emails(.:format) Controller#Action | rails/conductor/action_mailbox/inbound_emails#create --[ Route 12 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | new_rails_conductor_inbound_email Verb | GET URI | /rails/conductor/action_mailbox/inbound_emails/new(.:format) Controller#Action | rails/conductor/action_mailbox/inbound_emails#new --[ Route 13 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | edit_rails_conductor_inbound_email Verb | GET URI | /rails/conductor/action_mailbox/inbound_emails/:id/edit(.:format) Controller#Action | rails/conductor/action_mailbox/inbound_emails#edit --[ Route 14 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_conductor_inbound_email Verb | GET URI | /rails/conductor/action_mailbox/inbound_emails/:id(.:format) Controller#Action | rails/conductor/action_mailbox/inbound_emails#show --[ Route 15 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | Verb | PATCH URI | /rails/conductor/action_mailbox/inbound_emails/:id(.:format) Controller#Action | rails/conductor/action_mailbox/inbound_emails#update --[ Route 16 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | Verb | PUT URI | /rails/conductor/action_mailbox/inbound_emails/:id(.:format) Controller#Action | rails/conductor/action_mailbox/inbound_emails#update --[ Route 17 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | Verb | DELETE URI | /rails/conductor/action_mailbox/inbound_emails/:id(.:format) Controller#Action | rails/conductor/action_mailbox/inbound_emails#destroy --[ Route 18 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | new_rails_conductor_inbound_email_source Verb | GET URI | /rails/conductor/action_mailbox/inbound_emails/sources/new(.:format) Controller#Action | rails/conductor/action_mailbox/inbound_emails/sources#new --[ Route 19 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_conductor_inbound_email_sources Verb | POST URI | /rails/conductor/action_mailbox/inbound_emails/sources(.:format) Controller#Action | rails/conductor/action_mailbox/inbound_emails/sources#create --[ Route 20 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_conductor_inbound_email_reroute Verb | POST URI | /rails/conductor/action_mailbox/:inbound_email_id/reroute(.:format) Controller#Action | rails/conductor/action_mailbox/reroutes#create --[ Route 21 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_conductor_inbound_email_incinerate Verb | POST URI | /rails/conductor/action_mailbox/:inbound_email_id/incinerate(.:format) Controller#Action | rails/conductor/action_mailbox/incinerates#create --[ Route 22 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_service_blob Verb | GET URI | /rails/active_storage/blobs/redirect/:signed_id/*filename(.:format) Controller#Action | active_storage/blobs/redirect#show --[ Route 23 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_service_blob_proxy Verb | GET URI | /rails/active_storage/blobs/proxy/:signed_id/*filename(.:format) Controller#Action | active_storage/blobs/proxy#show --[ Route 24 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | Verb | GET URI | /rails/active_storage/blobs/:signed_id/*filename(.:format) Controller#Action | active_storage/blobs/redirect#show --[ Route 25 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_blob_representation Verb | GET URI | /rails/active_storage/representations/redirect/:signed_blob_id/:variation_key/*filename(.:format) Controller#Action | active_storage/representations/redirect#show --[ Route 26 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_blob_representation_proxy Verb | GET URI | /rails/active_storage/representations/proxy/:signed_blob_id/:variation_key/*filename(.:format) Controller#Action | active_storage/representations/proxy#show --[ Route 27 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | Verb | GET URI | /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) Controller#Action | active_storage/representations/redirect#show --[ Route 28 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_disk_service Verb | GET URI | /rails/active_storage/disk/:encoded_key/*filename(.:format) Controller#Action | active_storage/disk#show --[ Route 29 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | update_rails_disk_service Verb | PUT URI | /rails/active_storage/disk/:encoded_token(.:format) Controller#Action | active_storage/disk#update --[ Route 30 ]------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Prefix | rails_direct_uploads Verb | POST URI | /rails/active_storage/direct_uploads(.:format) Controller#Action | active_storage/direct_uploads#create
book_adminを指定したせいか、想定よりルーティング設定が多く少し驚きましたが、Rails の挙動を知ることができて有益でした。