I would need to get the actual Request from a model in rails 3. I know there is not always an request processed, but if there is one I would like to be able to access it. How is
You can store the request in the thread, and then access it anywhere. This is def a hack as you really should not break the MVC convention this way, and if a model is really request dependent you could always pass the request to the model as a parameter.
but the hack to make your request available everywhere would be for application_controller.rb:
before_filter :store_request_in_thread
def store_request_in_thread
Thread.current[:request] = request
end
and in your model somemodel.rb or really anywhere you expect request to already exist, you can just access the request:
def something
request = Thread.current[:request]
end