One configuration per domain name on the same application. How to easily access config values from m
Posted
by Aymeric
on Stack Overflow
See other posts from Stack Overflow
or by Aymeric
Published on 2010-06-01T08:48:08Z
Indexed on
2010/06/01
8:53 UTC
Read the original article
Hit count: 209
Hi,
I run a Ruby on Rails website that have multiple domain names. I have a "Website" table in the database that stores the configuration values related to each domain name:
Website
- domain
- name
- tagline
- admin_email
- etc...
At the moment, I load the website object at the start of each request (before_filter) in my ApplicationController:
@website = Website.find_by_domain(request.host)
The problem is when I need to access the @website object from my models methods. I would like to avoid to have to pass @website everywhere. The best solution would be to have something similar to APP_CONFIG but per domain name.
def sample_model_property
- - "#{@website.name} is a great website!"
end
How would you do it?
© Stack Overflow or respective owner