5

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.

snowangel
  • 3,452
  • 3
  • 29
  • 72
  • Since the question is related to the gem's feature/bug, I think it would be better to submit an issue or PR to the gem directly to get help quicker. – Billy Chan Jan 14 '14 at 14:50
  • Weeell, I feel a bit bad because I should probably keep things RESTful. It's a shortcoming of me, not the gem, really. – snowangel Jan 14 '14 at 14:52
  • I'm not familiar with this gem. But non-restful things are still needed in some cases. Maybe the maintainer has better opinion about it. – Billy Chan Jan 14 '14 at 14:56
  • I believe [`Wicked`](https://github.com/schneems/wicked) uses `id` to retrieve the step, so checking if `steps` array contains the passed `id` in the `show` action then rendering accordingly might be an option. – vee Jan 14 '14 at 15:04
  • Ooh, I like it. Ta -- I'll report back later. – snowangel Jan 14 '14 at 15:05

1 Answers1

9

You need to add:

skip_before_filter :setup_wizard, only: :waterfall

in your wicked controller

BroiSatse
  • 44,031
  • 8
  • 61
  • 86