4

您可以在包含 WickedWizard gem 的控制器中使用非静态方法吗?

控制器:

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

路线:

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

gem 的版本 1 和更低版本允许非 restful 操作,但是解决此 PR的此提交强制执行步骤名称。我去这条路线的错误 是http://localhost:3000/book_update/3949/waterfall

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

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

我想我应该启动一个新的控制器并将非宁静的动作塞进去,但替代方案会很棒。

4

1 回答 1

9

您需要添加:

skip_before_filter :setup_wizard, only: :waterfall

在你邪恶的控制器中

于 2014-01-14T15:16:57.340 回答