Class: UsersController

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

Instance Method Summary collapse

Methods included from SessionsHelper

#preferences_customer_type=, #preferences_customer_type?, #signed_in?, #signed_in_user, #store_location

Instance Method Details

#createObject



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

def create
  @user = User.new(params[:user])
  if @user.save
     @user
    flash[:success] = "Welcome to the Sample App!"
    redirect_to @user
  else
    render 'new'
  end
end

#destroyObject



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

def destroy
  User.find(params[:id]).destroy
  flash[:success] = "User destroyed."
  redirect_to users_path
end

#indexObject



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

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

#newObject



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

def new
  @user = User.new
end

#showObject



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

def show
  @user = User.find(params[:id])
  @microposts = @user.microposts.paginate(page: params[:page])
end

#updateObject



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

def update
  #@user = User.find(params[:id])
  if @user.update_attributes(params[:user])
    flash[:success] = "Profile updated"
     @user
    redirect_to @user
  else
    render 'edit'
  end
end