In my Rails 3.2 setup I had the following middleware:
@app = app
def call(env) request = Rack::Request.new(env) params = request.params cookies = request.env['action_dispatch.cookies'] session = request.env['rack.session'] requested_locale = params['locale'] || cookies['locale'] || I18n.default_locale session['locale'] = cookies['locale'] = locale @app.call(env) end
It was working fine until I’ve upgraded to Rails 4.0, where
cookies is nil and therefore I get the error:
NoMethodError: undefined method `’ for nil:NilClass
cookies['locale'] is called. What’s the proper way to do this in Rails 4.0?
P.S. Rack also was bumped from 1.4.6 to 1.5.5.