Class: Gluttonberg::Admin::Settings::ConfigurationsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- BaseController
- Gluttonberg::Admin::Settings::ConfigurationsController
- Defined in:
- app/controllers/gluttonberg/admin/settings/configurations_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
-
#index ⇒ Object
Confuguration/settings listing page.
- #new ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/gluttonberg/admin/settings/configurations_controller.rb', line 37 def create @setting = Setting.new(params["gluttonberg_setting"]) count = Setting.all.length @setting.row = count + 1 if @setting.save flash[:notice] = "The configuration was successfully created." redirect_to admin_configurations_path else render :new end end |
#delete ⇒ Object
67 68 69 70 71 72 73 |
# File 'app/controllers/gluttonberg/admin/settings/configurations_controller.rb', line 67 def delete display_delete_confirmation( :title => "Delete “#{@setting.name}” configuration?", :url => admin_configuration_path(@setting), :return_url => admin_configurations_path ) end |
#destroy ⇒ Object
75 76 77 78 79 80 81 |
# File 'app/controllers/gluttonberg/admin/settings/configurations_controller.rb', line 75 def destroy generic_destroy(@setting, { :name => "setting", :success_path => admin_configurations_path, :failure_path => admin_configurations_path }) end |
#edit ⇒ Object
34 35 |
# File 'app/controllers/gluttonberg/admin/settings/configurations_controller.rb', line 34 def edit end |
#index ⇒ Object
Confuguration/settings listing page
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/gluttonberg/admin/settings/configurations_controller.rb', line 13 def index # grab multisite settings @multisite = Rails.configuration.multisite.kind_of?(Hash) # grab all global settings @cms_settings = Setting.where("site is NULL or site=''").order("row asc").all # grab all settings for all sites @site_wise_settings = {} if @multisite Rails.configuration.multisite.each do |key, val| @site_wise_settings[key] = Setting.where(:site => key).order("row asc").all end end @settings = Setting.order("row asc").all @current_home_page_id = Page.home_page.id unless Page.home_page.blank? @pages = Page.all end |
#new ⇒ Object
30 31 32 |
# File 'app/controllers/gluttonberg/admin/settings/configurations_controller.rb', line 30 def new @setting = Setting.new end |
#update ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/gluttonberg/admin/settings/configurations_controller.rb', line 49 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 configuration was successfully updated." format.html redirect_to admin_configurations_path end else flash[:error] = "Sorry, The configuration could not be updated." render :edit end end |