Class: Virgo::Admin::UsersController

Inherits:
BaseController show all
Defined in:
app/controllers/virgo/admin/users_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#authorize_admin_user, #search, #set_is_admin_view

Methods included from RenderHelper

#render_content, #with_format

Methods included from Virgo::ApplicationHelper

#action?, #admin?, #admin_access?, #admin_view?, #alerts, #base_errors, #category_timestamp, #column_timestamp, #compact_html, #controller?, #decode_html_entities, #expanded_post_url, #is_admin_view?, #page_url, #post_time_format, #post_timestamp, #production?, #redis_timestamp_key_for, #site, #site_key, #superuser?, #tabbed_param, #word_count

Instance Method Details

#createObject


18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/virgo/admin/users_controller.rb', line 18

def create
  @user = User.new(user_params)

  if @user.save
    flash[:notice] = "Account created successfully"
    redirect_to admin_users_path
  else
    render :new
  end
end

#destroyObject


47
48
49
50
51
52
53
# File 'app/controllers/virgo/admin/users_controller.rb', line 47

def destroy
  @user.destroy

  flash[:notice] = "User successfully deleted"

  redirect_to admin_users_path
end

#editObject


29
30
# File 'app/controllers/virgo/admin/users_controller.rb', line 29

def edit
end

#indexObject


9
10
11
12
# File 'app/controllers/virgo/admin/users_controller.rb', line 9

def index
  authorize! :index, User
  @users = User.search(filter_params).with_post_count.order(sort_order).page(params[:page])
end

#newObject


14
15
16
# File 'app/controllers/virgo/admin/users_controller.rb', line 14

def new
  @user = User.new
end

#updateObject


32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/virgo/admin/users_controller.rb', line 32

def update
  _is_user = current_user == @user

  if @user.update(user_params)
    flash[:notice] = "Profile updated successfully"
    redirect_to edit_admin_user_path(@user)

    # required to keep user signed in (thanks to oddball default
    # devise policy of signing out a user who updates pw)
     @user, bypass: true if _is_user
  else
    render :edit
  end
end