Some Rails apps have to be available on multiple domains, for example, acmeinc.com, acmeinc.ru, acmeinc.com.au. Quite often in this case the app has to know the current domain to adjust the UI or do some customization.
This gem adds current_domain
helper method to all the controllers and views of the app. The method returns the host name at which the web app is currently accessed. It can also be customized to return custom objects for different domains if, for example, the app has Domain or Host model that represent each of the app domains.
Add this line to your application's Gemfile:
gem 'current_domain'
And then execute:
$ bundle
Or install it yourself as:
$ gem install current_domain
Once this gem is included into Gemfile of a Rails app, current_domain
helper method is available in all controllers and views of the applications. If an app has models or other classes that represent each app domain then add similar code to ApplicationController
to return custom objects instead of host names:
def find_domain(host)
Domain.find_by_host(host)
end
Your contribution is welcome.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request