Class: ConfigManager::AdminsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/config_manager/admins_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /admins



24
25
26
27
28
29
30
31
32
# File 'app/controllers/config_manager/admins_controller.rb', line 24

def create
  @admin = Admin.new admin_params
  if @admin.save
    flash[:notice] = "New admin user #{@admin.email} successfully created"
    redirect_to admins_path
  else
    render "new"
  end
end

#destroyObject

DELETE /admin/:id



35
36
37
38
39
40
41
42
# File 'app/controllers/config_manager/admins_controller.rb', line 35

def destroy
  @admin = Admin.find(params[:id])
  @admin.destroy
  redirect_to admins_path
rescue ActiveRecord::RecordNotFound
  flash[:error] = "Admin with id=#{params[:id]} couldn't be found"
  redirect_to admins_path
end

#editObject

GET /admin/:id/edit



16
17
18
19
20
21
# File 'app/controllers/config_manager/admins_controller.rb', line 16

def edit
  @admin = Admin.find(params[:id])
rescue ActiveRecord::RecordNotFound
  flash[:error] = "Admin with id=#{params[:id]} couldn't be found"
  redirect_to admins_path
end

#indexObject

GET /admins



4
5
6
7
8
# File 'app/controllers/config_manager/admins_controller.rb', line 4

def index
  page = params[:page] || 1
  per_page = params[:page] ? (params[:per_page] || PER_PAGE) : nil
  @admins = Admin.page(page).per(per_page)
end

#newObject

GET /admins/new



11
12
13
# File 'app/controllers/config_manager/admins_controller.rb', line 11

def new
  @admin = Admin.new admin_params
end