Class: Rearview::UserController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rearview/user_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



6
7
8
# File 'app/controllers/rearview/user_controller.rb', line 6

def show
  @user = current_user
end

#updateObject



9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/rearview/user_controller.rb', line 9

def update
  # https://github.com/rails/rails/issues/8831
  # https://github.com/rails/rails/issues/8832
  preferences = JSON.parse(request.body.string).with_indifferent_access.try(:[],:preferences)
  @user = current_user
  if preferences.present?
    @user.preferences = preferences
  end
  @user.save!
  render :show
end