Sha256: f4140eaf481b35965e3c6aac71ae20a97f40562af639da281ec665779cf4e3b1
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
module ConfigManager class AdminsController < ApplicationController # GET /admins def index page = params[:page] || 1 per_page = params[:page] ? (params[:per_page] || PER_PAGE) : nil @admins = Admin.page(page).per(per_page) end # GET /admins/new def new @admin = Admin.new admin_params end # GET /admin/:id/edit 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 # POST /admins 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 # DELETE /admin/:id 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 private def admin_params if strong_parameters? params[:admin] && params[:admin].permit(:email, :password, :password_confirmation) else params[:admin] end end def strong_parameters? Rails::VERSION::MAJOR >= 4 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
config_manager-0.0.1 | app/controllers/config_manager/admins_controller.rb |