Sha256: 09d46e8035a0fe5ce8a5888bffd4e228f77ac612c874e5e9328098d2a77990ec

Contents?: true

Size: 995 Bytes

Versions: 6

Compression:

Stored size: 995 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 @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 == :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

6 entries across 6 versions & 1 rubygems

Version Path
wicked-0.3.4 lib/wicked/controller/concerns/render_redirect.rb
wicked-0.3.3 lib/wicked/controller/concerns/render_redirect.rb
wicked-0.3.2 lib/wicked/controller/concerns/render_redirect.rb
wicked-0.3.1 lib/wicked/controller/concerns/render_redirect.rb
wicked-0.3.0 lib/wicked/controller/concerns/render_redirect.rb
wicked-0.2.0 lib/wicked/controller/concerns/render_redirect.rb