LoginSignup
20
19

More than 5 years have passed since last update.

Rails3.1でroutes.rbファイルを分割する

Last updated at Posted at 2012-03-16

複数人数で開発するときroutes.rbはコンフリクトの温床になりがちなので、分割する方法を調べた。

まずどんなフォルダ名でもいいはずだけど無難にmkdir config/routesなどをして、その下にroutes.rbの中身を一部切り出してやる。書式はroutes.rbとまったく同じ。

config/routes/omniauth.rb
 MyApp::Application.routes.draw do                                                                                                                                                            

  match '/auth/:provider/callback' => 'sessions#create'
  match '/auth/failure' => 'sessions#failure'
  match '/signout' => 'sessions#destroy', :as => :signout

end

application.rbでconfig.pathsを開き、切り出したファイルを、Railsがroutesとして認識するファイル一覧に追加する。

config/application.rb
 config.paths["config/routes"] << "config/routes/omniauth.rb" 
20
19
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
20
19