Class: Spud::UsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/spud/users_controller.rb

Instance Method Summary collapse

Methods included from ApplicationHelper

#current_site_id, #current_site_name, #sortable

Instance Method Details

#save_settingObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/spud/users_controller.rb', line 29

def save_setting
  if params[:key].blank?
    render :status => 500,:text => nil and return
  end

  setting = @current_user..where(:key => params[:key]).first
  if setting.blank?
    setting = @current_user..new(:key => params[:key])
  end
  setting.value = params[:value]
  if setting.save
    render :status => 200,:text => nil and return
  else
    render :status => 500,:text => nil and return
  end
end

#settingsObject



5
6
7
8
9
10
11
12
# File 'app/controllers/spud/users_controller.rb', line 5

def settings
  if current_user.has_admin_rights?
    add_breadcrumb "Dashboard", :spud_admin_root_path
  end
  add_breadcrumb "Settings", :spud_settings_path
  @page_thumbnail = "spud/admin/users_icon.png"
  @page_name = "Settings"
end

#updateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/spud/users_controller.rb', line 14

def update

  add_breadcrumb "Settings", :spud_settings_path
  @page_thumbnail = "spud/admin/users_icon.png"
  @page_name = "Settings"
  if @current_user.update_attributes(user_params)
    flash[:notice] = "User settings saved successfully."
    redirect_to spud_admin_root_url()
  else
    flash[:error] = "There was an error while saving the user."
    render :action => "settings"
  end
end