Skip to content

Instantly share code, notes, and snippets.

@ruhenheim
Last active June 19, 2019 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruhenheim/8b79e93f176b0d921275adf082664975 to your computer and use it in GitHub Desktop.
Save ruhenheim/8b79e93f176b0d921275adf082664975 to your computer and use it in GitHub Desktop.
Railsルーティング定義アレコレ
Rails.application.routes.draw do
scope '(:locale)', locale: /#{I18n.available_locales.map(&:to_s).join('|')}/ do
# ====================================
# For API
# ====================================
namespace :api do
namespace :v1 do
resources :companies, path: 'cm/', only: [] do
resources :provinces, only: :index, defaults: { format: 'json' }
end
end
end
# ====================================
# For users
# ====================================
root to: 'top#index'
...
# ====================================
# For agents
# ====================================
namespace :agent do
root to: 'dashboard#index'
...
end
match "/", to: "application#render_404", via: [:head, :post, :patch, :put, :delete, :options]
match "*path", to: "application#render_404", via: [:get, :head, :post, :patch, :put, :delete, :options]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment