Class: Georgia::UsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/georgia/users_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_ability, #current_locale

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
# File 'app/controllers/georgia/users_controller.rb', line 22

def create
  @user = User.new(params[:user])

  if @user.save
    redirect_to users_url, notice: "User was successfully created."
  else
    render 'new'
  end
end

#destroyObject



43
44
45
46
47
# File 'app/controllers/georgia/users_controller.rb', line 43

def destroy
  @user = User.find(params[:id])
  @user.destroy
  redirect_to users_url, notice: "User was successfully deleted."
end

#editObject



18
19
20
# File 'app/controllers/georgia/users_controller.rb', line 18

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

#indexObject



6
7
8
# File 'app/controllers/georgia/users_controller.rb', line 6

def index
  @users = User.order(:created_at).page(params[:page])
end

#newObject



14
15
16
# File 'app/controllers/georgia/users_controller.rb', line 14

def new
  @user = User.new
end

#showObject



10
11
12
# File 'app/controllers/georgia/users_controller.rb', line 10

def show
  redirect_to edit_user_path(params[:id])
end

#updateObject



32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/georgia/users_controller.rb', line 32

def update
  @user = User.find(params[:id])
  params[:user].delete(:password) if params[:user][:password].blank?
  params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
  if @user.update_attributes(params[:user])
    redirect_to users_url, notice: "User was successfully updated."
  else
    render 'edit'
  end
end