I am deploying an application to several sub domains and need to set a
global variable in each sub domain so that I query the correct table
based on the sub domain. Currently I am doing this in my layouts but
this doesn’t seem like a good practice.
Does anyone know of a way to set this global variable when I deploy
using capistrano?
On Mon, 2008-02-25 at 20:19 +0100, Lucas Campbell wrote:
I am deploying an application to several sub domains and need to set a
global variable in each sub domain so that I query the correct table
based on the sub domain.
Hm, sounds like something you could do in a controller - just check the
“Host” header of the incoming HTTP request.
On Mon, 2008-02-25 at 20:19 +0100, Lucas Campbell wrote:
I am deploying an application to several sub domains and need to set a
global variable in each sub domain so that I query the correct table
based on the sub domain.
Hm, sounds like something you could do in a controller - just check the
“Host” header of the incoming HTTP request.
Yours,
tom
I actually created a helper method that uses url_for to grab the url and
find out which subdomain its in and then set the global variable
accordingly.
I can’t access helper methods from my controller so I am using my layout
to call my helper method which sets the global varialbe. Only thing is,
since i call the helper from my layout, it is being called every time a
page is rendered.
I wanted to find a way to add something in my deploy.rb file to call the
helper method once so the global is set.
On Mon, 2008-02-25 at 20:49 +0100, Lucas Campbell wrote:
helper method once so the global is set.
Ah, I see. You could do an after :update_code task that appends a
variable declaration to your environment.rb file or puts a file in
shared/system/… hm, I wonder if you could just look at your RAILS_ROOT
from within the app and key off the directory names embedded there?
Yours,
tom
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.