Skip to content

Instantly share code, notes, and snippets.

@ruhenheim ruhenheim/routes.rb
Last active Jun 19, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.