LoginSignup
9
5

More than 5 years have passed since last update.

「その他全て」のルートを定義するには

Posted at

SPAを作りたいときなどRailsのルーティングが不要な場合があります。

Rails.application.routes.draw do
  # たとえばAPI
  constraints subdomain: /^api/ do
    mount Api::Root => '/'
    mount GrapeSwaggerRails::Engine => '/docs'
  end

  # それ以外はすべて
  get '*path', to: 'home#otherwise'
end

で、app/views/home/otherwise.html.erbにSPAを書けば良いです。

9
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
5