邪恶巫师控制器中的非休息动作



你能在包含邪恶巫师宝石的控制器中使用非休息方法吗?

控制器:

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.

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

您需要添加:

skip_before_filter :setup_wizard, only: :waterfall

在你邪恶的控制器中

最新更新