Sha256: 7ceaa0ad15226b8fb192052607fd1631b7725b71aae2b014e67e3b827e9a7413

Contents?: true

Size: 1.09 KB

Versions: 39

Compression:

Stored size: 1.09 KB

Contents

class Manage::AdminsController < Manage::ApplicationController
  before_action :find_user, only: [:show, :edit, :update, :destroy]

  respond_to :html

  def index
  end

  def datatable
    render json: AdminDatatable.new(view_context)
  end

  def show
    respond_with(:manage, @user)
  end

  def new
    @user = ::User.new
    respond_with(:manage, @user)
  end

  def edit
  end

  def create
    @user = ::User.new(user_params.merge(password: Devise.friendly_token.first(10)))
    if @user.save
      @user.update_attribute(:admin, true)
      @user.send_reset_password_instructions
    end
    respond_with(:manage, @user, location: manage_admins_path)
  end

  def update
    @user.update_attributes(user_params)
    respond_with(:manage, @user, location: manage_admins_path)
  end

  def destroy
    @user.destroy
    respond_with(:manage, @user, location: manage_admins_path)
  end

  private

  def user_params
    params.require(:user).permit(
      :email, :password, :password_confirmation, :remember_me, :admin_limited_access
    )
  end

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

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
hackathon_manager-0.10.0 app/controllers/manage/admins_controller.rb
hackathon_manager-0.9.2 app/controllers/manage/admins_controller.rb
hackathon_manager-0.9.1 app/controllers/manage/admins_controller.rb
hackathon_manager-0.9.0 app/controllers/manage/admins_controller.rb
hackathon_manager-0.8.2 app/controllers/manage/admins_controller.rb
hackathon_manager-0.8.1 app/controllers/manage/admins_controller.rb
hackathon_manager-0.8.0 app/controllers/manage/admins_controller.rb
hackathon_manager-0.7.1 app/controllers/manage/admins_controller.rb
hackathon_manager-0.7.0 app/controllers/manage/admins_controller.rb
hackathon_manager-0.6.6 app/controllers/manage/admins_controller.rb
hackathon_manager-0.6.5 app/controllers/manage/admins_controller.rb
hackathon_manager-0.6.4 app/controllers/manage/admins_controller.rb
hackathon_manager-0.6.3 app/controllers/manage/admins_controller.rb
hackathon_manager-0.6.2 app/controllers/manage/admins_controller.rb
hackathon_manager-0.6.1 app/controllers/manage/admins_controller.rb
hackathon_manager-0.6.0 app/controllers/manage/admins_controller.rb
hackathon_manager-0.5.11 app/controllers/manage/admins_controller.rb
hackathon_manager-0.5.10 app/controllers/manage/admins_controller.rb
hackathon_manager-0.5.9 app/controllers/manage/admins_controller.rb
hackathon_manager-0.5.8 app/controllers/manage/admins_controller.rb