Rails3 㧠routes.rb ãåå²ã»è¿½å ãã
æ ãã£ã¦ routes.rb ã routes/frontend.rb 㨠routes/backend.rb ã«åå²ãããã¨ããã
ã¨ããããã routes.rb ã®ä¸ã§ require ãªã load ãªããã¦ãããããããã ã¨éçºä¸ã« routes/frontend.rb ãç·¨éãã¦ããåèµ·åããªãéãåæ ãããªãã
SampleApp::Application.routes.draw do # : # : end require_relative 'routes/frontend.rb' require_relative 'routes/backend.rb'
ããããªãããã«ã¯ã該å½ã®ãã¡ã¤ã«ã routes ãã¡ã¤ã«ãã¹è¨å®ã«è¿½å ããã
config/application.rb ã®ä¸ã§ä»¥ä¸ã®ããã«è¨è¿°ããã
module SampleApp class Application < Rails::Application # : # : ãã®ä»ã®è¨å® # : config.paths.config.routes.concat Dir[Rails.root.join("config/routes/*.rb")] end end
ãããã¯è¿½å ããããã¹ãä¸ã¤ãªãã°ã config.paths.config.routes << Rails.root.join("config/routes/aroute.rb") ã¨ãã¦ãããããã ã
ï¼config.paths.config.routes 㯠Rails::Paths::Path ãªã®ã§ãã®ã¡ã½ãããåç
§ãï¼
ããã¦åãã¡ã¤ã«ã«æ®éã« routes.rb ã®ããã«ã«ã¼ãã£ã³ã°ãè¨è¿°ããã°ããã
èªã¿è¾¼ã¾ããé çªã«æ³¨æã追å ããé㨠éé ã§èªã¿è¾¼ã¾ãã ãããªãã¡ãå ã®ä¾ã§ããã°ä»¥ä¸ã®ãããªé 㧠load ããããã¨ã«ãªãã
- config/routes/frontend.rb
- config/routes/backend.rb
- config/routes.rb