Class: UsersController
Instance Method Summary
collapse
#preferences_customer_type=, #preferences_customer_type?, #signed_in?, #signed_in_user, #store_location
Instance Method Details
#create ⇒ Object
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
sign_in @user
flash[:success] = "Welcome to the Sample App!"
redirect_to @user
else
render 'new'
end
end
|
#destroy ⇒ Object
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
|
#index ⇒ Object
9
10
11
|
# File 'app/controllers/users_controller.rb', line 9
def index
@users = User.paginate(page: params[:page])
end
|
#new ⇒ Object
18
19
20
|
# File 'app/controllers/users_controller.rb', line 18
def new
@user = User.new
end
|
#show ⇒ Object
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
|
#update ⇒ Object
33
34
35
36
37
38
39
40
41
42
|
# File 'app/controllers/users_controller.rb', line 33
def update
if @user.update_attributes(params[:user])
flash[:success] = "Profile updated"
sign_in @user
redirect_to @user
else
render 'edit'
end
end
|