Sha256: 426b0f535ec9bfa692bf69172ab104956cffd2e0ea6242964ebcc55cb7184a8e

Contents?: true

Size: 1003 Bytes

Versions: 10

Compression:

Stored size: 1003 Bytes

Contents

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


  # scary and gross, allows for double render
  def _reset_invocation_response
    self.instance_variable_set(:@_response_body, nil)
    response.instance_variable_set :@header, Rack::Utils::HeaderHash.new("cookie" => [], 'Content-Type' => 'text/html')
  end


  def render_wizard(resource = nil)
    _reset_invocation_response
    @skip_to = @next_step if resource && resource.save
    if @skip_to.present?
      redirect_to wizard_path @skip_to
    else
      render_step  @step
    end
  end

  def render_step(the_step)
    if the_step.nil? || the_step == :finish
      redirect_to_finish_wizard
    else
      render the_step
    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

  def finish_wizard_path
    '/'
  end

  def redirect_to_finish_wizard
    redirect_to finish_wizard_path
  end

end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
wicked-0.1.5 lib/wicked/controller/concerns/render_redirect.rb
wicked-0.1.4 lib/wicked/controller/concerns/render_redirect.rb
wicked-0.1.3 lib/wicked/controller/concerns/render_redirect.rb
wicked-with-previous-support-0.2 lib/wicked/controller/concerns/render_redirect.rb
wicked-with-previous-support-0.1 lib/wicked/controller/concerns/render_redirect.rb
wicked-0.1.2 lib/wicked/controller/concerns/render_redirect.rb
wicked-0.1.1 lib/wicked/controller/concerns/render_redirect.rb
wicked-0.1.0 lib/wicked/controller/concerns/render_redirect.rb
wicked-0.0.2 lib/wicked/controller/concerns/render_redirect.rb
wicked-0.0.1 lib/wicked/controller/concerns/render_redirect.rb