Class: EasySettingsController

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

Overview

edit and update actions are for a plugin settings it uses a presenter, wich prefixes the settings name by a plugin id automatically

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
# File 'app/controllers/easy_settings_controller.rb', line 12

def create
  if @easy_settings.save
    redirect_to :back
  else
    render :new
  end
end

#editObject



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

def edit
  @settings = Setting.send "plugin_#{@plugin.id}"
end

#newObject



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

def new
end

#updateObject



24
25
26
27
28
29
30
31
32
# File 'app/controllers/easy_settings_controller.rb', line 24

def update
  Setting.send "plugin_#{@plugin.id}=", params[:settings] if params[:settings]
  if @easy_settings.save
    flash[:notice] = l(:notice_successful_update)
    redirect_back_or_default edit_easy_setting_path(@easy_settings)
  else
    render :edit
  end
end