Sha256: d44e30b2a8dcdfa1daa9b0a7429e2b249ee005c0084d85a4e584a6b08dfd052d

Contents?: true

Size: 1014 Bytes

Versions: 1

Compression:

Stored size: 1014 Bytes

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 == 'finish'
      redirect_to_finish_wizard options
    else
      render the_step, options
    end
  end

  def redirect_to_next(next_step)
    if next_step.nil?
      redirect_to_finish_wizard
    else
      redirect_to wizard_path(next_step)
    end
  end

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

  def redirect_to_finish_wizard(options = nil)
    redirect_to finish_wizard_path, options
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wicked-0.5.0 lib/wicked/controller/concerns/render_redirect.rb