Class: Gluttonberg::Admin::Settings::GenericSettingsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/gluttonberg/admin/settings/generic_settings_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/gluttonberg/admin/settings/generic_settings_controller.rb', line 25

def create
  @setting = Setting.new(params["gluttonberg_setting"])
  count = Setting.all.length
  @setting.row = count + 1
  if @setting.save
    flash[:notice] = "The article was successfully created."
    redirect_to admin_generic_settings_path
  else
    render :new
  end
end

#deleteObject



55
56
57
58
59
60
61
# File 'app/controllers/gluttonberg/admin/settings/generic_settings_controller.rb', line 55

def delete
  display_delete_confirmation(
    :title      => "Delete “#{@setting.name}” setting?",
    :url        => admin_generic_setting_path(@setting),
    :return_url => admin_generic_settings_path 
  )
end

#destroyObject



63
64
65
66
67
68
69
70
71
# File 'app/controllers/gluttonberg/admin/settings/generic_settings_controller.rb', line 63

def destroy
  if @setting.destroy
    flash[:notice] = "The setting was successfully deleted."
    redirect_to admin_generic_settings_path
  else
    flash[:error] = "There was an error deleting the setting."
    redirect_to admin_generic_settings_path
  end
end

#editObject



22
23
# File 'app/controllers/gluttonberg/admin/settings/generic_settings_controller.rb', line 22

def edit
end

#indexObject



12
13
14
15
16
# File 'app/controllers/gluttonberg/admin/settings/generic_settings_controller.rb', line 12

def index
  @settings = Setting.find(:all , :order => "row asc")
  @current_home_page_id  = Page.home_page.id unless Page.home_page.blank?
  @pages = Page.all
end

#newObject



18
19
20
# File 'app/controllers/gluttonberg/admin/settings/generic_settings_controller.rb', line 18

def new
  @setting = Setting.new
end

#updateObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/gluttonberg/admin/settings/generic_settings_controller.rb', line 37

def update
  if params.has_key? "gluttonberg/setting"
    params[:gluttonberg_setting] = params["gluttonberg/setting"]
  end  
  if @setting.update_attributes(params[:gluttonberg_setting])
    if request.xhr?
      render :text => @setting.value
    else
      flash[:notice] = "The setting was successfully updated."
      format.html redirect_to admin_generic_settings_path 
    end            
  else
    flash[:error] = "Sorry, The setting could not be updated."
    render :edit
  end
end