Class: Bagboy::UsersController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#initialize

Constructor Details

This class inherits a constructor from Bagboy::ApplicationController

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
# File 'app/controllers/bagboy/users_controller.rb', line 21

def create
  @user = Bagboy::User.new(user_params)
  if @user.save
    redirect_to users_path, flash: { success: "You have succesfully created #{@user.email}"}
  else
    render 'new'
  end
end

#deleteObject



45
46
47
48
49
# File 'app/controllers/bagboy/users_controller.rb', line 45

def delete
  @user = Bagboy::User.find(params[:id])
  @user.delete
  redirect_to users_path, flash: { success: "#{@user.email} successfuly deleted!"}
end

#editObject



30
31
32
33
# File 'app/controllers/bagboy/users_controller.rb', line 30

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

#indexObject



11
12
13
14
# File 'app/controllers/bagboy/users_controller.rb', line 11

def index
  @users = Bagboy::User.all
  render :index
end

#newObject



16
17
18
19
# File 'app/controllers/bagboy/users_controller.rb', line 16

def new
  @user = Bagboy::User.new
  render :new
end

#showObject



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

def show
  @user = Bagboy::User.find(params[:id])
  render :show
end

#updateObject



35
36
37
38
39
40
41
42
43
# File 'app/controllers/bagboy/users_controller.rb', line 35

def update
  @user = Bagboy::User.find(params[:id])
  @user.update_attributes( user_params )
  if ( @user.save )
    redirect_to user_path( @user.id ), flash: { success: "You have succesfully updated #{@user.email}!"}
  else
    render :edit
  end
end