Skip to content

Commit

Permalink
Merge pull request #2062 from jvortmann/fix_logout_path_and_method
Browse files Browse the repository at this point in the history
Fix #1386 by removing dependency of Devise for logout_path and logout_method.
  • Loading branch information
sferik committed Sep 7, 2014
2 parents f420baa + 6f4dd05 commit 5b03a6e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions app/helpers/rails_admin/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ def edit_user_link
end

def logout_path
return unless defined?(Devise)
scope = Devise::Mapping.find_scope!(_current_user)
main_app.send("destroy_#{scope}_session_path") rescue false
if defined?(Devise)
scope = Devise::Mapping.find_scope!(_current_user)
main_app.send("destroy_#{scope}_session_path") rescue false
else
main_app.logout_path if main_app.respond_to?(:logout_path)
end
end

def logout_method
return Devise.sign_out_via if defined?(Devise)
:delete
end

def wording_for(label, action = @action, abstract_model = @abstract_model, object = @object)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
- if user_link = edit_user_link
%li= user_link
- if logout_path.present?
%li= link_to content_tag('span', t('admin.misc.log_out'), class: 'label label-important'), logout_path, method: Devise.sign_out_via
%li= link_to content_tag('span', t('admin.misc.log_out'), class: 'label label-important'), logout_path, method: logout_method
- if _current_user.respond_to?(:email) && _current_user.email.present?
%li= image_tag "#{(request.ssl? ? 'https://secure' : 'http://www')}.gravatar.com/avatar/#{Digest::MD5.hexdigest _current_user.email}?s=30", style: 'padding-top:5px'

0 comments on commit 5b03a6e

Please sign in to comment.