Hi, I have the simplest rails app: my only controller says: class MaxmindController < ApplicationController @ip = request end my index.rhtml in the views/maxmind folder says: <%= debug @ip %> the result of trying to view this in firefox is: NameError in MaxmindController#index undefined local variable or method `request'' for MaxmindController:Class if I remove the one line from my controller and change my view code to: <%= debug request %> then i get my request object nicely displayed. Why is request available only in the view and not in the controller? I''m running this locally under locomotive. Thanks, Gabor --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Because you''re out of scope. @ip = request is in the class scope, and request is not available there. Try using a before_filter. class MaxmindController < ApplicationController before_filter :get_ip protected def get_ip @ip = request.remote_ip end end On 6/15/07, gabordemeter <gabordemeter-YbzV19J7KiEAvxtiuMwx3w@public.gmane.org> wrote:> > > Hi, > > I have the simplest rails app: > > my only controller says: > > class MaxmindController < ApplicationController > @ip = request > end > > my index.rhtml in the views/maxmind folder says: > > <%= debug @ip %> > > > the result of trying to view this in firefox is: > > > NameError in MaxmindController#index > > undefined local variable or method `request'' for > MaxmindController:Class > > > > if I remove the one line from my controller and change my view code > to: > > <%= debug request %> > > then i get my request object nicely displayed. > > > Why is request available only in the view and not in the controller? > I''m running this locally under locomotive. > > > Thanks, > > Gabor > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Xeno Campanoli
2007-Jun-15 19:57 UTC
Re: Configuring the Server: Page 7 of ROR Up and Running script/server content differs
Xeno Campanoli wrote:> My copy of ROR/UAR has something like: > > ... > OPTIONS = { > :port => 3000 > etc. > > but my actual file I got installed was: > > #!/usr/bin/env ruby > require File.dirname(__FILE__) + ''/../config/boot'' > require ''commands/server'' > ---snip--- > I cannot find anything but README and a log with grep -lRi webrick * > from that chapter-1 directory either. What gives? > > xc >-- The only sustainable organizing methods focus not on scale, but on good design of the functional unit, not on winning battles, but on preservation. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---