Class: ConfigManager::AdminsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ConfigManager::AdminsController
- Defined in:
- app/controllers/config_manager/admins_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /admins.
-
#destroy ⇒ Object
DELETE /admin/:id.
-
#edit ⇒ Object
GET /admin/:id/edit.
-
#index ⇒ Object
GET /admins.
-
#new ⇒ Object
GET /admins/new.
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
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 |
#index ⇒ Object
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 |
#new ⇒ Object
GET /admins/new
11 12 13 |
# File 'app/controllers/config_manager/admins_controller.rb', line 11 def new @admin = Admin.new admin_params end |