Sha256: 087093f42dfe5e79092cbba3b9cbc35181dd235796361f870d727ac1bc64523f

Contents?: true

Size: 1.48 KB

Versions: 24

Compression:

Stored size: 1.48 KB

Contents

module Spina
  module Admin
    class UsersController < AdminController
      before_filter :set_breadcrumbs
      
      authorize_resource class: User

      layout "spina/admin/settings"

      def index
        @users = User.all
      end

      def new
        @user = User.new
        add_breadcrumb I18n.t('spina.users.new')
      end

      def create
        @user = User.new(user_params)
        add_breadcrumb I18n.t('spina.users.new')
        if @user.save
          redirect_to admin_users_url
        else
          flash.now[:alert] = I18n.t('spina.users.cannot_be_created')
          render :new
        end
      end

      def edit
        @user = User.find(params[:id])
        add_breadcrumb "#{@user}"
      end

      def update
        @user = User.find(params[:id])
        add_breadcrumb "#{@user}"
        if @user.update_attributes(user_params)
          redirect_to spina.admin_users_url
        else
          flash.now[:alert] = I18n.t('spina.users.cannot_be_created')
          render :edit
        end
      end

      def destroy
        @user = User.find(params[:id])
        @user.destroy unless @user == current_user
        redirect_to admin_users_url
      end

      private

      def set_breadcrumbs
        add_breadcrumb I18n.t('spina.preferences.users'), spina.admin_users_path
      end

      def user_params
        params.require(:user).permit(:admin, :email, :name, :password_digest, :password, :password_confirmation, :last_logged_in)
      end
      
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
spina-0.8.3 app/controllers/spina/admin/users_controller.rb
spina-0.8.2 app/controllers/spina/admin/users_controller.rb
spina-0.8.1 app/controllers/spina/admin/users_controller.rb
spina-0.8.0 app/controllers/spina/admin/users_controller.rb
spina-0.7.3 app/controllers/spina/admin/users_controller.rb
spina-0.7.2 app/controllers/spina/admin/users_controller.rb
spina-0.7.0 app/controllers/spina/admin/users_controller.rb
spina-0.6.29 app/controllers/spina/admin/users_controller.rb
spina-0.6.28 app/controllers/spina/admin/users_controller.rb
spina-0.6.27 app/controllers/spina/admin/users_controller.rb
spina-0.6.26 app/controllers/spina/admin/users_controller.rb
spina-0.6.25 app/controllers/spina/admin/users_controller.rb
spina-0.6.24 app/controllers/spina/admin/users_controller.rb
spina-0.6.23 app/controllers/spina/admin/users_controller.rb
spina-0.6.22 app/controllers/spina/admin/users_controller.rb
spina-0.6.21 app/controllers/spina/admin/users_controller.rb
spina-0.6.20 app/controllers/spina/admin/users_controller.rb
spina-0.6.19 app/controllers/spina/admin/users_controller.rb
spina-0.6.18 app/controllers/spina/admin/users_controller.rb
spina-0.6.17 app/controllers/spina/admin/users_controller.rb