Sha256: 17c0036728f069d02d9260ca43f2f6c9be4bb48e1a63037db452e9be55a8417b

Contents?: true

Size: 932 Bytes

Versions: 3

Compression:

Stored size: 932 Bytes

Contents

class Cambium::Admin::SettingsController < Cambium::AdminController

  before_filter :not_found, :except => [:index, :update]

  def index
    expected_keys = admin_view.form.edit.fields.to_h.stringify_keys.keys
    current_keys = Cambium::Setting.keys
    # Add anything that's missing
    (expected_keys - current_keys).each do |key|
      Cambium::Setting.create(:key => key)
    end
    @collection = admin_model.alpha
    # Remove anything extra
    extra_keys = @collection.collect(&:key) - expected_keys
    if extra_keys.size > 0
      Cambium::Setting.where(:key => extra_keys).destroy_all
      @collection = admin_model.alpha
    end
    respond_to do |format|
      format.html
      format.csv { send_data admin.to_csv(@collection) }
    end
  end

  private

    def create_params
      obj = admin_model.to_s.gsub(/Cambium::/, '').tableize.singularize.to_sym
      p = params.require(obj).permit(:value)
    end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cambium-1.3.2 app/controllers/cambium/admin/settings_controller.rb
cambium-1.3.1 app/controllers/cambium/admin/settings_controller.rb
cambium-1.3.0 app/controllers/cambium/admin/settings_controller.rb