Splitting Routes File Into Multiple Files

前端 未结 4 1560

I\'m working w/ a Rails 3 application and I want to split up the routes into separate files depending on the subdomain. Right now I have this in my routes.rb file:



        
4条回答
  •  温柔的废话
    2020-12-18 21:45

    Add the route file to the app route loading path:

    # config/application.rb
    config.paths.config.routes << File.join(Rails.root, "config/routes/fooroutes.rb")
    

    Wrap your other route file in a block like this.

    #config/routes/fooroutes.rb
    Rails.application.routes.draw do |map|
      match 'FOO' => 'foo/bar'
    end
    

    Works for me in rails 3.0

提交回复
热议问题