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.
F68e4842b0a5487678e26046fdb2fdf3?d=identicon&s=25 softwareengineer 99 (Guest)
on 2006-02-08 17: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
59de94a56fd2c198f33d9515d1c05961?d=identicon&s=25 Tom Mornini (Guest)
on 2006-02-08 17: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 Mornini
F68e4842b0a5487678e26046fdb2fdf3?d=identicon&s=25 softwareengineer 99 (Guest)
on 2006-02-08 20: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 Mornini <tmornini@infomania.com> wrote:  Not worth it, if you ask
me.
This topic is locked and can not be replied to.