Class: UsersController

Inherits:
ApplicationController show all
Includes:
Applicat::Mvc::Controller::Resource
Defined in:
app/controllers/users_controller.rb

Instance Method Summary collapse

Methods included from Applicat::Mvc::Controller::Resource

included

Methods inherited from ApplicationController

#current_ability

Methods included from Voluntary::V1::BaseController

#parent, #voluntary_application_javascripts, #voluntary_application_stylesheets

Methods included from Applicat::Mvc::Controller

included

Instance Method Details

#destroyObject



37
38
39
40
# File 'app/controllers/users_controller.rb', line 37

def destroy
  current_user.destroy
  redirect_to users_url, notice: t('general.form.destroyed')
end

#editObject



20
21
# File 'app/controllers/users_controller.rb', line 20

def edit
end

#indexObject



8
9
10
11
# File 'app/controllers/users_controller.rb', line 8

def index
  parent = find_parent User::PARENT_TYPES
  @users = parent ? parent.users : User.all
end

#languagesObject



13
14
15
# File 'app/controllers/users_controller.rb', line 13

def languages
  render json: User.languages(params[:q]).to_json and return
end

#preferencesObject



23
24
25
26
27
# File 'app/controllers/users_controller.rb', line 23

def preferences
  if params[:user] && current_user.update_attributes(params[:user])
    redirect_to preferences_user_path(current_user), notice: t('general.form.successfully_updated') and return
  end
end

#resourceObject



42
43
44
# File 'app/controllers/users_controller.rb', line 42

def resource
  @user
end

#showObject



17
18
# File 'app/controllers/users_controller.rb', line 17

def show
end

#updateObject



29
30
31
32
33
34
35
# File 'app/controllers/users_controller.rb', line 29

def update
  if current_user.update_attributes(params[:user])
    redirect_to edit_user_path(current_user), notice: t('general.form.successfully_updated')
  else
    render :edit
  end
end