Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non restful actions in Wicked Wizard controller

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.

like image 445
snowangel Avatar asked Jan 12 '23 11:01

snowangel


1 Answers

You need to add:

skip_before_filter :setup_wizard, only: :waterfall

in your wicked controller

like image 95
BroiSatse Avatar answered Jan 17 '23 17:01

BroiSatse