On Monday, August 17, 2015 at 1:51:38 PM UTC+1, powi wrote: > > 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 > > when `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.
The cookies middleware in rails doesn't look like it has changed. However env["actiondispatch.cookies"] is only set lazily - perhaps previously there was some other middleware that was causing it to be set for you? If so then you need to set env["actiondispatch.cookies"] if it is nil If you create an actiondispatch::request rather than rack::request then you'll get a cookies method on request that does that for you. Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/cd2ea256-1ec4-40be-a142-40e5e3919a79%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

