Skip to content

rails_admin doesn't work if devise mapping does not have email field #734

Closed
baranov1ch opened this Issue Sep 23, 2011 · 1 comment

2 participants

@baranov1ch

I removed email field from my devise mapping, so now it is authenticated via "login"
Now when authentication succeeded and I'm being redirected to rails_admin dashboard, I get the following:

Showing C:/Ruby192/lib/ruby/gems/1.9.1/bundler/gems/rails_admin-8a247378542d/app/views/layouts/rails_admin/_header.html.haml where line #12 raised:

undefined method `email' for #Admin:0x45364c8

Extracted source (around line #12):
9: - if _current_user
10: - if authorized?(:edit, _current_user.class, _current_user)
11: %li= link_to header_icon(:account, _current_user.email), edit_path(_current_user.class.name.underscore.pluralize, _current_user)
12: - if defined?(Devise)
13: %li= link_to header_icon(:logout, t('admin.credentials.log_out')), main_app.url_for(:action => 'destroy', :controller => 'devise/sessions'), :method => Devise.sign_out_via

Which is obvious, since email field is missing :)
For now I just added dummy email field to my model, but should it be somehow more beautiful, isn't it?

@gunn
Collaborator
gunn commented Sep 23, 2011

_current_user.try :email is the answer. Think you could make a pull request?

@gunn gunn closed this in 3ba35c5 Oct 4, 2011
@gunn gunn added a commit that referenced this issue Oct 4, 2011
@gunn gunn 3rd time lucky for #734 fix. 1cb0628
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.