Sha256: b4e71452ff9d77868ec28651f08b33566603d813591e374f421aff26ed92613b

Contents?: true

Size: 1.63 KB

Versions: 11

Compression:

Stored size: 1.63 KB

Contents

module Refinery
  module <%= class_name.pluralize %>
    module Admin
      class SettingsController < Refinery::AdminController

        before_filter :check_setting, :only => [:edit, :update]
        after_filter :save_subject_for_confirmation, :save_message_for_confirmation, :only => :update

        def edit
          @setting = Refinery::Setting.find(params[:id])
        end

        def update
          @setting = Refinery::Setting.find(params[:id])

          if @setting.update_attributes(params[:setting])
            flash[:notice] = t('refinery.crudify.updated', :what => @setting.name.gsub("<%= singular_name %>_", "").titleize)

            unless request.xhr? or from_dialog?
              redirect_back_or_default(refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path)
            else
              render :text => "<script type='text/javascript'>parent.window.location = '#{refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path}';</script>"
            end
          end
        end

      protected
        def check_setting
          setting = params[:id].gsub("<%= singular_name %>_", "")

          Refinery::<%= namespacing %>::Setting.send(setting) if Refinery::<%= namespacing %>::Setting.respond_to?(setting)
        end

        def save_subject_for_confirmation
          Refinery::<%= namespacing %>::Setting.confirmation_subject = params[:subject] if params.keys.include?('subject')
        end

        def save_message_for_confirmation
          Refinery::<%= namespacing %>::Setting.confirmation_message = params[:message] if params.keys.include?('message')
        end

      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
refinerycms-core-2.1.5 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/settings_controller.rb.erb
refinerycms-core-2.1.4 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/settings_controller.rb.erb
refinerycms-core-2.1.3 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/settings_controller.rb.erb
refinerycms-core-2.1.2 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/settings_controller.rb.erb
refinerycms-core-2.1.1 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/settings_controller.rb.erb
refinerycms-core-2.1.0 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/settings_controller.rb.erb
refinerycms-core-2.0.10 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/settings_controller.rb.erb
refinerycms-core-2.0.9 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/settings_controller.rb.erb
refinerycms-core-2.0.8 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/settings_controller.rb.erb
refinerycms-core-2.0.7 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/settings_controller.rb.erb
refinerycms-core-2.0.6 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/settings_controller.rb.erb