Sha256: ab42bc39943cfa2a80c52334caf46f8769dec656a57d1fb990477a787aa5ff92

Contents?: true

Size: 913 Bytes

Versions: 3

Compression:

Stored size: 913 Bytes

Contents

class Admin::UsersController < ApplicationController
	before_action { |c| c.authorize_level(Snapuser.superuser_level) }
	layout Snapuser.layout

	def index
		@table = Table.new(self, User)
		@table.respond
	end

	def new
		@user = User.new
	end

	def create
		@user = User.new(user_params)
		if @user.save
			redirect_to admin_users_path, success: t('snapuser.admin.new.success')
		else
			render 'new'
		end
	end

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

	def update
		@user = User.find(params[:id])
		if @user.update_attributes(user_params)
			redirect_to admin_users_path, success: t('snapuser.admin.edit.success')
		else
			render 'edit'
		end
	end

	def destroy
		User.find(params[:id]).destroy
		redirect_to admin_activities_path, success: t('snapuser.admin.destroy.success')
	end

	private

	def user_params
		params.require(:user).permit(:name, :level, :password, :password_confirmation)
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
snapuser-0.2.3 app/controllers/admin/users_controller.rb
snapuser-0.2.2 app/controllers/admin/users_controller.rb
snapuser-0.2.1 app/controllers/admin/users_controller.rb