Permalink
Browse files

Work if devise mapping does not have email field. Closes #734.

  • Loading branch information...
1 parent b8da2bb commit 3ba35c5295a7d9c5c49be5cd6b2472802bd37a84 @gunn gunn committed Oct 4, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 app/views/layouts/rails_admin/_header.html.haml
@@ -8,6 +8,6 @@
%li= link_to header_icon(:home, t('home.name').capitalize), main_app_root_path
- if _current_user
- if authorized?(:edit, _current_user.class, _current_user)
- %li= link_to header_icon(:account, _current_user.email), edit_path(_current_user.class.name.underscore.pluralize, _current_user)
+ %li= link_to header_icon(:account, _current_user.try(:email)), edit_path(_current_user.class.name.underscore.pluralize, _current_user)
- if defined?(Devise)
%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

2 comments on commit 3ba35c5

Collaborator

bbenezech replied Oct 4, 2011

You need to test for _current_user.responds_to?(:email)
Object#try will simply return nil if Object#instance.is_a?(NilClass), and we already tested _current_user presence at 3ba35c5#L0R9

Collaborator

gunn replied Oct 4, 2011

@bbenezech err right. Fixed now.

Please sign in to comment.