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 received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---