Class: Admin::ConfigurationController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/configuration_controller.rb

Instance Method Summary collapse

Instance Method Details

#editObject



20
21
22
# File 'app/controllers/admin/configuration_controller.rb', line 20

def edit
  render
end

#showObject



15
16
17
18
# File 'app/controllers/admin/configuration_controller.rb', line 15

def show
  @user = current_user
  render
end

#updateObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/admin/configuration_controller.rb', line 24

def update
  if params[:trusty_config]
    begin
      TrustyCms.config.transaction do
        params[:trusty_config].each_pair do |key, value|
          @trusty_config[key] = TrustyCms::Config.find_or_initialize_by(key: key)
          @trusty_config[key].value = value      # validation sets errors on @trusty_config['key'] that the helper methods will pick up
        end
        redirect_to :action => :show
      end
    rescue ActiveRecord::RecordInvalid => e
      flash[:error] = "Configuration error: please check the form"
      render :action => :edit
    rescue TrustyCms::Config::ConfigError => e
      flash[:error] = "Configuration error: #{e}"
      render :action => :edit
    end
  end
end