Forum: Ruby on Rails Best way to know the domain across all controllers?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
softwareengineer 99 (Guest)
on 2006-02-08 18:23
(Received via mailing list)
Hello,
  I would like to use something like
  domain=request.domain
  and be able to access the domain variable across all my controllers.

  What is the best way to do so? In which file can I put the above
variable declaration and still be able to access it application wide?

  I guess I am asking on assistance for using global variables in rails.

  Can anyone please guide me to a source or help me figure this out.

  Thanks
  Frank
Tom M. (Guest)
on 2006-02-08 18:37
(Received via mailing list)
application.rb

def set_domain
   @domain=request.domain
end

In your controllers...

before_filter :set_domain

All that gets you, though, is the ability to replace:

   request.domain

with

   @domain

Not worth it, if you ask me.

--
-- Tom M.
softwareengineer 99 (Guest)
on 2006-02-08 21:34
(Received via mailing list)
Hi Tom,
  Thank you for your reply.
  I was interested in understanding  the concept so your reply did help.

  Thanks
  Frank

Tom M. <removed_email_address@domain.invalid> wrote:  Not worth it, if you ask
me.
This topic is locked and can not be replied to.