Sha256: d56e1930167a2ca39f33df186ba5ed4576d19077661c54b3144fe789c3dc2d38

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

module Wicked::Controller::Concerns::RenderRedirect
  extend ActiveSupport::Concern


  def render_wizard(resource = nil, options = {})
    process_resource!(resource)

    if @skip_to
      redirect_to wizard_path(@skip_to), options
    else
      render_step wizard_value(step), options
    end
  end

  def process_resource!(resource)
    if resource
      if resource.save
        @skip_to ||= @next_step
      else
        @skip_to = nil
      end
    end
  end

  def render_step(the_step, options = {})
    if the_step.nil? || the_step.to_s == Wicked::FINISH_STEP
      redirect_to_finish_wizard options
    else
      render the_step, options
    end
  end

  def redirect_to_next(next_step, options = {})
    if next_step.nil?
      redirect_to_finish_wizard(options)
    else
      redirect_to wizard_path(next_step), options
    end
  end

  # TODO redirect to resource if one is passed to render_wizard
  def finish_wizard_path
    '/'
  end

  def redirect_to_finish_wizard(options = {})
    redirect_to finish_wizard_path, options
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wicked-1.0.2 lib/wicked/controller/concerns/render_redirect.rb
wicked-1.0.0 lib/wicked/controller/concerns/render_redirect.rb