Sha256: 8236142e28efdf52fbb231d3c0590c0285972f3fc2a41d8c5a4b77977c4768b5
Contents?: true
Size: 1.84 KB
Versions: 2
Compression:
Stored size: 1.84 KB
Contents
module Effective module WizardController extend ActiveSupport::Concern unless defined?(Wicked) raise("please install gem 'wicked' to use Effective::WizardController") end include Wicked::Wizard include Effective::CrudController include Effective::WizardController::Actions include Effective::WizardController::BeforeActions include Effective::WizardController::Save included do with_options(only: [:show, :update]) do before_action :redirect_if_blank_step before_action :assign_resource before_action :authorize_resource before_action :assign_required_steps before_action :setup_wizard # Wicked before_action :enforce_can_visit_step before_action :assign_current_step before_action :assign_page_title end helper_method :resource helper_method :resource_wizard_step_title helper EffectiveResourcesWizardHelper rescue_from Wicked::Wizard::InvalidStepError do |exception| flash[:danger] = "Unknown step. You have been moved to the #{resource_wizard_steps.first} step." redirect_to wizard_path(resource_wizard_steps.first) end end def find_wizard_resource if params[resource_name_id] && params[resource_name_id] != 'new' resource_scope.find(params[resource_name_id]) else resource_scope.new end end def resource_wizard_step_title(step) return if step == 'wicked_finish' effective_resource.klass.const_get(:WIZARD_STEPS).fetch(step) end def resource_wizard_steps effective_resource.klass.const_get(:WIZARD_STEPS).keys end def resource_wizard_path(resource, step) path_helper = effective_resource.action_path_helper(:show).to_s.sub('_path', '_build_path') public_send(path_helper, resource, step) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
effective_resources-1.6.5 | app/controllers/concerns/effective/wizard_controller.rb |
effective_resources-1.6.4 | app/controllers/concerns/effective/wizard_controller.rb |