Sha256: 89f96b834f291da2a5516c7dc279294df50441a4abd93a56c5bff522938192fb

Contents?: true

Size: 1.3 KB

Versions: 15

Compression:

Stored size: 1.3 KB

Contents

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

  before_filter :find_optional_project
  before_filter :prepare_presenter
  before_filter :find_plugin, only: [:edit, :update]

  def new
  end

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

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

  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 redmine_extensions_engine.edit_easy_setting_path(@easy_settings)
    else
      render :edit
    end
  end

  private
    def find_optional_project
      @project = Project.find(params[:project_id]) unless params[:project_id].blank?
    end

    def prepare_presenter
      @easy_settings = RedmineExtensions::EasySettingPresenter.new(params[:easy_setting], @project)
    end

    def find_plugin
      @plugin = Redmine::Plugin.find(params[:id])

      return render_404 unless @plugin.settings.is_a?(Hash)

      @easy_settings.plugin = @plugin

    rescue Redmine::PluginNotFound
      render_404
    end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
redmine_extensions-0.1.10 app/controllers/easy_settings_controller.rb
redmine_extensions-0.0.36 app/controllers/easy_settings_controller.rb
redmine_extensions-0.0.34 app/controllers/easy_settings_controller.rb
redmine_extensions-0.1.09 app/controllers/easy_settings_controller.rb
redmine_extensions-0.1.07 app/controllers/easy_settings_controller.rb
redmine_extensions-0.1.06 app/controllers/easy_settings_controller.rb
redmine_extensions-0.1.05 app/controllers/easy_settings_controller.rb
redmine_extensions-0.1.04 app/controllers/easy_settings_controller.rb
redmine_extensions-0.1.03 app/controllers/easy_settings_controller.rb
redmine_extensions-0.0.33 app/controllers/easy_settings_controller.rb
redmine_extensions-0.1.02 app/controllers/easy_settings_controller.rb
redmine_extensions-0.1.01 app/controllers/easy_settings_controller.rb
redmine_extensions-0.0.29 app/controllers/easy_settings_controller.rb
redmine_extensions-0.0.28 app/controllers/easy_settings_controller.rb
redmine_extensions-0.0.27 app/controllers/easy_settings_controller.rb