Finish user edit, update, index, and destroy actions
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
-
-
-
-
-
-
-
resolved all discussions
Toggle commit list -
-
merged
Toggle commit list
Step 1. Fetch and check out the branch for this merge request
git fetch origin git checkout -b updating-users origin/updating-users
Step 2. Review the changes locally
Step 3. Merge the branch and fix any conflicts that come up
git checkout master git merge --no-ff updating-users
Step 4. Push the result of the merge to GitLab
git push origin master
Note that pushing to GitLab requires write access to this repository.
Tip: You can also checkout merge requests locally by following these guidelines.
| 1 | 1 | class UsersController < ApplicationController |
| 2 | include SessionsHelper | |
| 3 | ||
| 4 | before_action :logged_in_user, only: [:index, :edit, :update, :destroy] | |
| 5 | before_action :correct_user, only: [:edit, :update] | |
| 6 | before_action :admin_user, | |
| 7 | only: :destroy | |
Please
register
or
sign in
to reply
|
||
| 1 | 1 | class UsersController < ApplicationController |
| 2 | include SessionsHelper | |
| 3 | ||
| 4 | before_action :logged_in_user, only: [:index, :edit, :update, :destroy] | |
| 5 | before_action :correct_user, only: [:edit, :update] | |
| 6 | before_action :admin_user, | |
| 7 | only: :destroy | |
| 2 | 8 | def show |
|
||
| 32 | def edit | |
| 33 | @user = User.find(params[:id]) | |
| 34 | end | |
| 35 | ||
| 36 | def update | |
| 37 | @user = User.find(params[:id]) | |
| 38 | if @user.update(user_params) | |
| 39 | flash[:success] = "Profile updated" | |
| 40 | redirect_to @user | |
| 41 | else | |
| 42 | render 'edit' | |
| 43 | end | |
| 44 | end | |
| 45 | ||
| 22 | 46 | private |
| 23 | 47 | def user_params |
|
||
| 1 | <% provide(:title, "Edit user") %> | |
| 2 | <h1>Update your profile</h1> | |
| 3 | <div class="row"> | |
| 4 | <div class="col-md-6 offset-md-3"> | |
| 5 | <%= form_with(model: @user, local: true) do |f| %> | |
|
||
| 1 | 1 | Rails.application.routes.draw do |
| 2 | 2 | |
| 3 | get 'sessions/new' | |
|
||
added 1 commit
resolved all discussions
resolved all discussions
mentioned in commit c44a8299
mentioned in commit c44a8299
merged