Question

Can you have non-restful methods in a controller which includes the WickedWizard gem?

Controller:

class Books::BookUpdateController < ApplicationController

  include Wicked::Wizard
  steps :title_step,  :ai_archive_step, :ai_override_step #etc

   def show
      ...
   end

   def update
      ...
   end

   def waterfall
      ...# loads of code to set up instance variables in the view, which I don't want to have to include in the normal show action for all the wizard steps. 
   end
end

Routes:

resources :book_update do     
  member do
    get 'waterfall'
    ... and others 
  end
end

Version 1 and lower of the gem allows non restful actions, but this commit to solve this PR enforces step names. My error on going to this route http://localhost:3000/book_update/3949/waterfall is

Wicked::Wizard::InvalidStepError in Books::BookUpdateController#waterfall

The requested step did not match any steps defined for this controller.

I suppose I should spark up a new controller and tuck the non restful actions into there, but alternatives would be great.

Was it helpful?

Solution

You need to add:

skip_before_filter :setup_wizard, only: :waterfall

in your wicked controller

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top