Skip to content

calls to controller unrelated to main steps triggers steps to become jumbled #268

Open
@jbeyer05

Description

If I have a Wizard controller where there is a function for AJAX calls that aren't directly related to the main Wizard steps, the Wizard steps seem to become jumbled. The essence of my Wizard controller is pasted at the bottom.

Two user paths to 'jumble' the step state machine:

  • User is on step1 and triggers a call to do_something_ajax( ). User refreshes the step1 page with F5. Wizard sends a 302 and redirects the user to step2.

  • User is on step1 and triggers a call to do_something_ajax( ). User submits form to move to step2. User then navigates 'back' in the browser. Step1 creates a 302 and redirects user back to step2.

Neither of the behaviors are as I would expect. I don't expect a call to do_something_ajax( ) to increment the Wizard steps. If the user does not generate any calls to do_something_ajax( ), everything works as expected.

Am I doing something wrong, or is this a bug with Wizard?

Thanks in advance!

class CheckoutController < ApplicationController
  include Wicked::Wizard

  steps :step1, :step2, :step3

  def do_something_ajax
    @checkout.something_happened = true

    respond_to do |format|
      format.js
    end
  end

  def new
    @checkout = Checkout.create( user: current_user )

    redirect_to checkout_path( @checkout ) # this ends up being step1 of the wizard
  end

  def show
    case step
      when :step1

      when :step2

      when :step3

  end

  def update
    case step
      when :step1

      when :step2

      when :step3

  end
end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions