Sha256: 0d77c7797a60653312d0f9c535e5b85c0646d087bc991917476ab51889adc71f

Contents?: true

Size: 1.24 KB

Versions: 15

Compression:

Stored size: 1.24 KB

Contents

module Dorsale
  class UsersController < ::Dorsale::ApplicationController
    handles_sortable_columns

    before_action :set_user, only: [
      :show,
      :edit,
      :update,
    ]

    def show

    end

    def index
      authorize! :list, User
      @users = User.all
    end

    def new
      @user = User.new
      authorize! :create, @user
    end

    def edit
      authorize! :update, @user
    end

    def create
      @user = User.new(user_params)
      authorize! :create, @user
      if @user.save
        redirect_to dorsale.users_path, notice: t("messages.users.create_ok")
      else
        flash[:error] = t("messages.users.create_error")
        render :new
      end
    end

    def update
      authorize! :update, @user
      if @user.update(user_params)
        redirect_to dorsale.users_path, notice: t("messages.users.update_ok")
      else
        flash[:error] = t("messages.users.update_error")
        render :edit
      end
    end

    private

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

    def permitted_params
      [
      :email,
      :password,
      :password_confirmation,
      :is_active,
      ]
    end

    def user_params
      params.require(:user).permit(permitted_params)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
dorsale-2.2.10 app/controllers/dorsale/users_controller.rb
dorsale-2.2.9 app/controllers/dorsale/users_controller.rb
dorsale-2.2.8 app/controllers/dorsale/users_controller.rb
dorsale-2.2.6 app/controllers/dorsale/users_controller.rb
dorsale-2.2.5 app/controllers/dorsale/users_controller.rb
dorsale-2.2.4 app/controllers/dorsale/users_controller.rb
dorsale-2.2.3 app/controllers/dorsale/users_controller.rb
dorsale-2.2.2 app/controllers/dorsale/users_controller.rb
dorsale-2.2.1 app/controllers/dorsale/users_controller.rb
dorsale-2.2.0 app/controllers/dorsale/users_controller.rb
dorsale-2.1.15 app/controllers/dorsale/users_controller.rb
dorsale-2.1.14 app/controllers/dorsale/users_controller.rb
dorsale-2.1.13 app/controllers/dorsale/users_controller.rb
dorsale-2.1.12 app/controllers/dorsale/users_controller.rb
dorsale-2.1.11 app/controllers/dorsale/users_controller.rb