I am doing some experiments with Mountable Engines. First i need your opinion for a scenario, Is it a good idea that we make "chunk of large modules" in an application as "mountable engines".
I tried this it works great, In mountable engine we can access models of app globally and in app we can access engine models with module prefix. So it works great for me.
Now came to original question:
I want to mount an engine to a subdomain, so that every request with specific subdomain should be served by that specific engine. I used this code.
root :to=>'dashboard#index'
scope :subdomain => 'admin' do
mount MyAdmin::Engine => '/'
end
In this case mydomain.com
and admin.mydomain.com
goes to dashboard controller
. If i change the preferences like that
scope :subdomain => 'admin' do
mount MyAdmin::Engine => '/'
end
root :to=>'dashboard#index'
In this case mydomain.com
and admin.mydomain.com
goes to engine specific root controller
.
How can we accomplish this scenario and mount an engine on specific sub-domain?
I accomplish the task by using these route entries:
scope :subdomain => 'www' do
root :to=>'dashboard#index'
end
scope :subdomain => 'admin' do
mount MyAdmin::Engine => '/'
end
Working with Rails 3.2.12 and ruby 1.9.3-194 I came to a different solution that also works locally for avoiding the www. subdomain issue while allowing there to be an Engine at a certain subdomain.
get "home/index"
constraints :subdomain => 'store' do
mount Spree::Core::Engine, :at => '/'
end
root :to => 'home#index'
I could totally be wrong but it's working so far.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With