Rails: how can I access the request object outside a helper or controller?
Posted
by rlandster
on Stack Overflow
See other posts from Stack Overflow
or by rlandster
Published on 2010-04-05T03:02:13Z
Indexed on
2010/04/05
3:03 UTC
Read the original article
Hit count: 321
In my application_helper.rb
file I have a function like this:
def internal_request?
server_name = request.env['SERVER_NAME']
[plus more code...]
end
This function is needed in controllers, model, and views. So, I put this code in a utility function file in the lib/
directory. However, this did not work: I got complaints about request
not being defined.
How can I access the request
object in a file in the lib/
directory?
© Stack Overflow or respective owner