Can we get request in application controller?

Hi, I'm trying to use my application controller to define my website
object (thus helping me find which template to use, etc).

I have this code in ApplicationController

sitename = request.host
sitename = "www." + sitename unless sitename.split('.')[2]
$website = Website.find_by_title( sitename )

but I get undefined local variable or method `request' for
ApplicationController:Class

Any ideas?

Hi, I'm trying to use my application controller to define my website
object (thus helping me find which template to use, etc).

I have this code in ApplicationController

sitename = request.host
sitename = "www." + sitename unless sitename.split('.')[2]
$website = Website.find_by_title( sitename )

but I get undefined local variable or method `request' for
ApplicationController:Class

Any ideas?

You have it directly in ApplicationController? That's probably not what you want.

You probably want this:

class ApplicationController < ActionController::Base

   before_filter :determine_website

   private
   def determine_website
     sitename = request.host
     sitename = "www." + sitename unless sitename.split('.')[2]
     @website = Website.find_by_title( sitename )
   end

end

Then you can reference @website in your actions and views.

-philip