Multiple route files

I found change in rails default path for routes:

3.2:

Rails.application.config.paths[“config/routes”]

4.0:

Rails.application.config.paths[“config/routes.rb”]

This was introduced in https://github.com/rails/rails/commit/6acebb38bc0637bc05c19d87f8767f16ce79189b and later on removed (but without path change) in favor of https://github.com/rails/rails/compare/fa736e69a197…2d9dbf416b14

Multiple route files feature can be easly achived by:

config.paths[“config/routes”].concat(Dir[Rails.root.join(“config/routes/*.rb”)])

Now it need to be changed to:

config.paths[“config/routes.rb”].concat(Dir[Rails.root.join(“config/routes/*.rb”)])

which looks like something terribly wrong is going on - concatenating multiple files to path that is pointing to single file (routes.rb).

I’m wondering if this can be changed back and Rails could provide “official” way of supporting multiple route files just as posted above without any changes to existing DSL.

Let me know if this approach shouldn’t be used for any reason - it works for me for a long time without any problems.

Anyone have some opinion about that?

We added this and removed it for a reason. It's really easy to roll your own, just use ruby:

Steve that is exactly what I’m doing.

But as you can see there is no more config.paths[“config/routes”] but config.paths[“config/routes.rb”] and it looks inappropriate when concatenating array to that “file”: config.paths[“config/routes.rb”].concat(Dir[Rails.root.join(“config/routes/*.rb”)])

W dniu wtorek, 12 marca 2013 16:36:25 UTC+1 użytkownik Steve Klabnik napisał: