Class: Blogr::UsersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Blogr::UsersController
- Defined in:
- app/controllers/blogr/users_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
23 24 25 |
# File 'app/controllers/blogr/users_controller.rb', line 23 def edit @title = "Editing '#{@user.username}'" end |
#index ⇒ Object
8 9 10 11 |
# File 'app/controllers/blogr/users_controller.rb', line 8 def index @title = "Users" @users = Blogr::User.all end |
#new ⇒ Object
18 19 20 21 |
# File 'app/controllers/blogr/users_controller.rb', line 18 def new @title = "New User" @user = User.new end |
#show ⇒ Object
13 14 15 16 |
# File 'app/controllers/blogr/users_controller.rb', line 13 def show @title = @user.username @posts = @user.posts end |
#update ⇒ Object
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 |