0.0
No commit activity in last 3 years
No release in over 3 years
Adds current_domain helper method to ActionController::Base
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.6.1, ~> 2.6
~> 3
~> 0.30

Runtime

 Project Readme

CurrentDomain

Build Status Code Climate Test Coverage

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.

Installation

Add this line to your application's Gemfile:

gem 'current_domain'

And then execute:

$ bundle

Or install it yourself as:

$ gem install current_domain

Usage

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

Contributing

Your contribution is welcome.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request