Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jbeyer05 opened this issue Jul 2, 2020 · 1 comment

Comments

@jbeyer05
Copy link

jbeyer05 commented Jul 2, 2020

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
@schneems
Copy link
Member

Can you give me an example app that reproduces the bug? https://www.codetriage.com/example_app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants