Class: Auth::My::UsersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/auth/my/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



40
41
42
43
44
45
46
47
# File 'app/controllers/auth/my/users_controller.rb', line 40

def destroy
  @user.destroy

  respond_to do |format|
    format.html { redirect_to my_user_url }
    format.json { head :no_content }
  end
end

#editObject



12
13
# File 'app/controllers/auth/my/users_controller.rb', line 12

def edit
end

#showObject



4
5
6
7
8
9
10
# File 'app/controllers/auth/my/users_controller.rb', line 4

def show
  respond_to do |format|
    format.js
    format.html
    format.json { render json: @user }
  end
end

#updateObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/auth/my/users_controller.rb', line 15

def update
  @user.assign_attributes user_params

  flash[:notice] = 'User was successfully updated.'

  if @user.email_changed?
    logout
    flash[:notice] = 'Your Email changed, please login again!'
    UserMailer.email_confirm(@user.email).deliver_later
  end

  respond_to do |format|
    if @user.save
      format.js
      format.html { redirect_to my_user_url }
      format.json {
        render json: { user: @user.as_json, filename: url_for(@user.avatar) }
      }
    else
      format.html { render action: 'edit' }
      format.json { render json: @user.errors, status: :unprocessable_entity }
    end
  end
end