Tim Michaud
2007-Dec-01 05:04 UTC
AbstractRequest request methods outside of Application.rb
I''m trying to access methods like request.request_uri and request.domain outside of the normal application and view code. How might one access these with code in /lib? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Greg Willits
2007-Dec-01 06:18 UTC
Re: AbstractRequest request methods outside of Application.rb
On Nov 30, 2007, at 9:04 PM, Tim Michaud wrote:> I''m trying to access methods like request.request_uri and > request.domain > outside of the normal application and view code. How might one access > these with code in /lib?pass those from your controller into the methods you''re calling. #------------------ # /controllers/whatever_controller.rb class WhateverController < ActionController::Base @some_var = LibThing.new @some_var.some_lib_method(self.request.subdomains) end #------------------ # /lib/lib_thing.rb class LibThing def some_lib_method(subdomains) # does stuf with request.subdomains here end end -- def gw acts_as_n00b writes_at(www.railsdev.ws) end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Tim Michaud
2007-Dec-02 20:10 UTC
Re: AbstractRequest request methods outside of Application.r
Greg Willits wrote:> > pass those from your controller into the methods you''re calling. >Hey Greg, thanks for the idea. I have tried this and it works well, but I''ve run into two problems. 1. I need to call this method about 5-20 times per request, so I''d like to be able to abstract the value out and not have to pass the same value for each call. (The method does take 2 other parameters, so each call is different). 2. But the bigger issue is that I''m finding that i need to call the "some_lib_method" in "/lib/lib_thing.rb" from other code in /lib - like in "/lib/other_lib_thing.rb". So what I''m wondering is, is there a way to include or require ActionController::AbstractRequest or something similar in "/lib/lib_thing.rb" so that its methods have direct access to request.request_uri and the like? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---