How to set rack environment variable from inside Rails -


rack-cache gem relies on @env['rack.errors'] setting log error messages:

    78:       # write log message rack.errors     79:       if verbose?     80:         binding.pry     81:         message = "cache: [%s %s] %s\n" %     82:           [@request.request_method, @request.fullpath, trace]  => 83:         @env['rack.errors'].write(message)     84:       end 

it set @env['rack.errors'] #⇒ #<io:<stderr>>.

i need change use rails.logger. obvious opportunity hack rack-cache initializer rails_cache.logger = .... wonder whether there common way access rack environment rails, (pseudocode):

rails.rack_env['rack.errors'] = rails.logger 

the rack environment accessible within context of request, hence in controller or view.

to access environment can use

request.env['whatever'] 

be careful when modify rack environment other pieces of rails stack may rely on it.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -