class Administration::SettingsController < ApplicationController
  
  def index
    @settings = Setting.find_all_by_site_id_and_hidden(
      Site.current.id,
      false,
      :order => 'section, name'
    ).group_by &:section
  end
  
  def batch
    Setting.find_all_by_site_id(Site.current.id).each do |setting|
      next if setting.hidden?
      value = params[setting.id.to_s]
      value = value.split(/\n/) if value and setting.format == 'list'
      value = value == '' ? nil : value
      setting.update_attributes! :value => value
    end
    Setting.precache_settings(true)
    flash[:notice] = 'Settings saved.'
    redirect_to administration_settings_path
  end
end

class Administration::SettingsController < ApplicationController
  
  def index
    @settings = Setting.find_all_by_site_id_and_hidden(
      Site.current.id,
      false,
      :order => 'section, name'
    ).group_by &:section
  end
  
  def batch
    Setting.find_all_by_site_id(Site.current.id).each do |setting|
      next if setting.hidden?
      value = params[setting.id.to_s]
      value = value.split(/\n/) if value and setting.format == 'list'
      value = value == '' ? nil : value
      setting.update_attributes! :value => value
    end
    Setting.precache_settings(true)
    expire_fragment(%r{views/})
    flash[:notice] = 'Settings saved.'
    redirect_to administration_settings_path
  end
end

Expire all caches when changing settings.
Expire all caches when changing settings.
