Sha256: a31301697d1406b2c789558040a8f03a88593804933669bdede7ea47068b605a

Contents?: true

Size: 813 Bytes

Versions: 2

Compression:

Stored size: 813 Bytes

Contents

class RailsSettingsUi::SettingsController < RailsSettingsUi::ApplicationController
  before_filter :collection
  before_filter :cast_settings_params, only: :update_all

  def index
  end

  def update_all
    if @casted_settings[:errors].any?
      render :index
    else
      @casted_settings.map { |setting| Settings[setting[0]] = setting[1] if setting[0] != "errors" }
      redirect_to [:settings]
    end
  end

  private

  def collection
    all_settings = Settings.defaults.merge(Settings.get_all)
    all_settings_without_ignored = all_settings.reject{ |name, description| RailsSettingsUi.ignored_settings.include?(name.to_sym) }
    @settings = Hash[all_settings_without_ignored]
  end

  def cast_settings_params
    @casted_settings = RailsSettingsUi::TypeConverter.cast(params["settings"])
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails-settings-ui-0.1.1 app/controllers/rails_settings_ui/settings_controller.rb
rails-settings-ui-0.1.0 app/controllers/rails_settings_ui/settings_controller.rb