-
-
Save tbuehlmann/90cc5fa1ad4b00f6d670b1f74716c248 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Started PATCH "/users/28/edit" for 192.168.0.100 at 2016-09-23 22:40:26 +0200 | |
Processing by UsersController#edit as HTML | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"BILLq+y8oXYL6aECCZCPONCAalsaKMYfZWFB50J3kNRQCSdt1Fy+X17fExIXML0bi5p00mH07lXXJNKOecytjA==", "user"=>{"name"=>"Name Update", "email"=>"[email protected]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "button"=>"", "id"=>"28"} | |
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 28], ["LIMIT", 1]] | |
Rendering users/edit.html.erb within layouts/application | |
Rendered shared/_errors.html.erb (0.4ms) | |
Rendered users/edit.html.erb within layouts/application (3.6ms) | |
Rendered application/_favicon.html.erb (8.4ms) | |
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 28], ["LIMIT", 1]] | |
Rendered layouts/_header.html.erb (3.6ms) | |
Rendered layouts/_flash_messages.html.erb (0.3ms) | |
Rendered cookies_eu/_cookies_eu.html.erb (0.4ms) | |
Rendered layouts/_footer.html.erb (1.1ms) | |
Completed 200 OK in 71ms (Views: 69.2ms | ActiveRecord: 0.6ms) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= render "shared/errors", object: @user %> | |
<h2 class="ui center aligned icon header"> | |
<i class="circular user icon"></i> | |
Edit User | |
</h2> | |
<%= form_for @user do |f| %> | |
<div class="ui form ui raised segment"> | |
<h4 class="ui dividing header">Personal Information</h4> | |
<div class="two fields"> | |
<div class="field"> | |
<%= f.label :name, 'Full name' %> | |
<%= f.text_field :name, autofocus: true %> | |
</div> | |
<div class="field"> | |
<label for="txtPosition">Account valid to</label> | |
<input type="text" placeholder="September 18, 2017" readonly=""> | |
</div> | |
</div> | |
<h4 class="ui dividing header">Contact Information</h4> | |
<div class="field"> | |
<%= f.label :email %> | |
<%= f.email_field :email %> | |
</div> | |
<h4 class="ui dividing header">Password</h4> | |
<div class="two fields"> | |
<div class="field"> | |
<%= f.label :password %> | |
<%= f.password_field :password, autocomplete: 'off' %> | |
</div> | |
<div class="field"> | |
<%= f.label :password_confirmation %> | |
<%= f.password_field :password_confirmation, autocomplete: 'off' %> | |
</div> | |
</div> | |
<h4 class="ui dividing header">Delete Account</h4> | |
<div class="field"> | |
<%= link_to @user, | |
data: { confirm: 'This will delete this account! Are you sure?' }, | |
method: :delete, | |
class: 'negative ui basic button' do %> | |
<i class="trash icon"></i>Delete Account | |
<% end %> | |
</div> | |
</div> | |
<%= f.button :submit, class: 'ui right floated labeled icon basic positive button' do %> | |
<i class="save icon"></i>Update | |
<% end %> | |
<% end %> | |
<%= link_to 'Back', users_path %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
resources :messages | |
devise_for :users, :controllers => { omniauth_callbacks: 'omniauth_callbacks', registrations: 'registrations' } | |
resources :analyses | |
resources :daily_overviews | |
root 'static_pages#home' | |
match '/users/:id/finish_signup' => 'users#finish_signup', via: [:get, :patch], :as => :finish_signup | |
get '/users/' => 'users#index' | |
namespace :admin do | |
resources :users | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/admin/users_controller.rb | |
class Admin::UsersController < ApplicationController | |
before_action :set_user, only: [:show, :edit, :update, :destroy, :finish_signup] | |
def show | |
end | |
def index | |
@users = User.all | |
end | |
def edit | |
end | |
def update | |
if @user.update(user_params) | |
redirect_to @user, notice: 'Profile was successfully updated.' | |
else | |
render :edit | |
end | |
end | |
def finish_signup | |
if request.patch? && params[:user] #&& params[:user][:email] | |
if @user.update(user_params) | |
@user.skip_reconfirmation! | |
bypass_sign_in(@user) | |
redirect_to @user, notice: 'Your profile was successfully updated.' | |
else | |
@show_errors = true | |
end | |
end | |
end | |
def destroy | |
@user.destroy | |
redirect_to root_url | |
end | |
private | |
def set_user | |
@user = User.find(params[:id]) | |
end | |
def user_params | |
params.require(:user).permit(:name, :email, :password, :password_confirmation) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment