Class: Blogr::UsersController

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

Instance Method Summary collapse

Instance Method Details

#createObject



27
28
29
30
31
32
33
34
35
# File 'app/controllers/blogr/users_controller.rb', line 27

def create
	@user = User.new(user_params)

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

#destroyObject



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

def destroy
	@user.destroy
	redirect_to users_path, notice: "User was successfully destroyed"
end

#editObject



23
24
25
# File 'app/controllers/blogr/users_controller.rb', line 23

def edit
	@title = "Editing '#{@user.username}'"
end

#indexObject



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

def index
	@title = "Users"
	@users = Blogr::User.all
end

#newObject



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

def new
	@title = "New User"
	@user = User.new
end

#showObject



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

def show
	@title = @user.username
	@posts = @user.posts
end

#updateObject



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

def update
	if @user.update(user_params)
		redirect_to users_path, notice: "User was successfully updated"
	else
		render action: "edit"
	end
end