using that gem you don't even need the with block thing.
with
you can for example in the controller:
RequestLocals[:request] = request
and then in the model:
if RequestLocals[:request].remote_ip == some_ip ...do something end
I agree that request_store_rails would be an alternative solution for my problems.
request_store_rails
Maybe I'm missing something but the with block is the "clean up mechanism".
def with(request_value) if get.present? raise ContextAlreadyDefinedError, "Context already defined!" end begin @@request_value.value = request_value yield ensure @@request_value.value = nil # "clean up mechanism" end end
totally, my bad!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
using that gem you don't even need the
with
block thing.you can for example in the controller:
and then in the model:
I agree that
request_store_rails
would be an alternative solution for my problems.Maybe I'm missing something but the
with
block is the "clean up mechanism".totally, my bad!