Skip to content

Commit

Permalink
Configure gem for ActiveAdmin
Browse files Browse the repository at this point in the history
  • Loading branch information
fladson committed Sep 19, 2017
1 parent feefafe commit f579adc
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/admin/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
column :username
column :role
column :authy_enabled
column do |user|
link_to("Sign in as #{user.name}", impersonate_engine.impersonate_user_path(user))
end
end

filter :email
Expand Down
4 changes: 4 additions & 0 deletions app/models/admin_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ class AdminUser < ActiveRecord::Base
devise :authy_authenticatable, :database_authenticatable, :trackable, :validatable

validates :email, presence: true

def staff?
true
end
end
40 changes: 40 additions & 0 deletions config/initializers/user_impersonate.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module UserImpersonate
class Engine < Rails::Engine
# Devise user model
config.user_class = 'User'

# User model lookup method
config.user_finder = 'find'

# Staff user model lookup method
config.staff_finder = 'find'

# User model primary key attribute
config.user_id_column = 'id'

# User model name attribute used for search
# Usage: User.where('#{user_name_column} like ?', '%#{params[:search]}%')
config.user_name_column = 'name'

# User model staff attribute
config.user_is_staff_method = 'staff?'

# Redirect to this path when entering impersonate mode
config.redirect_on_impersonate = '/'

# Redirect to this path when leaving impersonate mode
config.redirect_on_revert = '/manage/users'

# Devise method used to sign user in
config.sign_in_user_method = 'sign_in'

# For Active Admin "AdminUser" model, use 'AdminUser'
config.staff_class = 'AdminUser'

# For Active Admin "AdminUser" model, use 'authenticate_admin_user!'
config.authenticate_user_method = 'authenticate_admin_user!'

# For Active Admin "AdminUser" model, use 'current_admin_user'
config.current_staff = 'current_admin_user'
end
end

0 comments on commit f579adc

Please sign in to comment.