Class: SupplejackApi::Admin::UsersController

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

Instance Method Summary collapse

Methods inherited from BaseController

#restrict_to_admin_users!

Methods inherited from SupplejackApi::ApplicationController

#authenticate_admin!, #authenticate_user!, #current_user, #find_user_set

Instance Method Details

#editObject


34
35
36
# File 'app/controllers/supplejack_api/admin/users_controller.rb', line 34

def edit
  @user = User.find(params[:id])
end

#indexObject


17
18
19
# File 'app/controllers/supplejack_api/admin/users_controller.rb', line 17

def index
  @users = User.sortable(order: params[:order] || :daily_requests_desc, page: params[:page])
end

#showObject


21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/supplejack_api/admin/users_controller.rb', line 21

def show
  @user = User.find(params[:id])
  @api_requests = LazyHighCharts::HighChart.new('graph') do |f|
    f.title(text: 'API requests/day for the last 90 days')
    f.series(name: 'API Requests',
             data: @user.requests_per_day(90),
             pointStart: 89.days.ago,
             pointInterval: 1.day)
    f.xAxis(type: :datetime)
    f.yAxis(title: { text: 'Number of Requests' }, min: 0)
  end
end

#updateObject


38
39
40
41
42
43
44
45
46
# File 'app/controllers/supplejack_api/admin/users_controller.rb', line 38

def update
  @user = User.find(params[:id])

  if @user.update_attributes(user_params)
    redirect_to admin_users_path
  else
    render :edit
  end
end