4

I'm wanting to make use of the new modularity prospects offered by the architecture changes in rails 3. However, rather than just mount an engine as in the majority of examples...

Rails.application.routes.draw do
  match "/blog" => Rack::Blog
end

...I'd like to mount multiple versions of the same engines, and have those instances independently configured. Something along the lines of...

Rails.application.routes.draw do
  match "/news" => Blog.new("path/to/blog_1/config")
  match "/blog" => Blog.new("path/to/blog_2/config")
end

Is this sort of functionality catered for? Has anyone implemented anything similar?

Thanks, fturtle

fturtle
  • 365
  • 1
  • 5
  • 17
  • hello, i find myself in the same situation, has Rails 4 implemented something that makes this possible? – caesarsol Mar 12 '15 at 18:50

1 Answers1

1

My gut tells me no, because the namespacing of the first implementation would step on the toes of the second. Though since the files would be the same I guess that wouldn't matter? How did you get on in the end?

Brendon Muir
  • 4,540
  • 2
  • 33
  • 55
  • Think we ended up doing something like the devise gem - creating an object/method that's available to the router, and that can dynamically write the routes based on some input. – fturtle Nov 21 '11 at 09:44
  • @fturtle, how do you implement it? We are having the same situation of mounting the same engine multiple times. Thanks. – user938363 Sep 19 '13 at 17:05
  • 1
    Take a look at this file: https://github.com/plataformatec/devise/blob/master/lib/devise/rails/routes.rb That's the method `devise_for` that's being called in the routes file. – Brendon Muir Sep 19 '13 at 23:27