Tuesday, 10 September 2013

Rails 4 lambda route request.session not yet loaded

Rails 4 lambda route request.session not yet loaded

I'm having trouble trying to access the request session in one of my route
constraints. I've used something like this in Rails 3 before and I've seen
tutorials using something similar on other sites as well. For some reason
though in Rails 4 this no longer works. Do I have to make adjustments to
the middle ware loading?
config/routes.rb
admin_constraint = lambda do |request|
request.session[:user_id] == 1
end
Exception that is raised:
#<ActionDispatch::Request::Session:0x7fc878b35400 not yet loaded>

No comments:

Post a Comment