Class: Admin::SiteConfigsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/admin/site_configs_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#require_admin, #set_active_menu

Methods inherited from ApplicationController

#fresh_when, #redirect_back_or_default, #redirect_referrer_or_default, #render_403, #render_404, #render_optional_error_file, #require_user, #set_active_menu, #set_locale, #set_seo_meta, #store_location, #unread_notify_count

Instance Method Details

#editObject


9
10
# File 'app/controllers/admin/site_configs_controller.rb', line 9

def edit
end

#get_settingObject


22
23
24
25
# File 'app/controllers/admin/site_configs_controller.rb', line 22

def get_setting
  @site_config = Setting.find_by(var: params[:id]) || Setting.new(var: params[:id])
  @site_config[:value] = Setting[params[:id]]
end

#indexObject


5
6
7
# File 'app/controllers/admin/site_configs_controller.rb', line 5

def index
  @site_configs = Setting.get_all
end

#updateObject


12
13
14
15
16
17
18
19
20
# File 'app/controllers/admin/site_configs_controller.rb', line 12

def update
  if @site_config.value != params[:setting][:value]
    @site_config.value = YAML.load(params[:setting][:value])
    @site_config.save
    redirect_to admin_site_configs_path, notice: '保存成功.'
  else
    redirect_to admin_site_configs_path
  end
end