Reputation: 201
I have a site online that currently uses rails admin and is what I have been using to track the users and other metrics for the site. However today when I went to my site I suddenly get a 500 internal error when I visit /admin. I have not updated or changed my code in a while so I can not for the life of me figure out whats going wrong.
Here is the error from the heroku logs:
2015-04-22T04:38:57.431281+00:00 app[web.1]: Started GET "/admin" for
108.162.249.51 at 2015-04-22 04:38:57 +0000
2015-04-22T04:38:57.435082+00:00 app[web.1]: Completed 500 Internal Server Error in 1ms
2015-04-22T04:38:57.436300+00:00 app[web.1]:
2015-04-22T04:38:57.436302+00:00 app[web.1]: NoMethodError (undefined method `admin' for nil:NilClass):
2015-04-22T04:38:57.436304+00:00 app[web.1]: config/initializers/rails_admin.rb:4:in `block (2 levels) in <top (required)>'
2015-04-22T04:38:57.436306+00:00 app[web.1]:
2015-04-22T04:38:57.434381+00:00 app[web.1]: Processing by RailsAdmin::MainController#dashboard as HTML
2015-04-22T04:38:57.436305+00:00 app[web.1]:
It works locally so I dont know what is happening. Also here is the code from that error:
#config/initializers/rails_admin.rb:4
redirect_to main_app.root_path unless warden.user.admin
I checked the console as well and that account still has admin active
Upvotes: 1
Views: 251
Reputation: 6940
warden.user
isn't being set. I would change the code to
redirect_to main_app.root_path unless warden.user.try(:admin)
Upvotes: 1