Wicked Wizard控制器中的非静止动作

时间:2014-01-14 14:38:11

标签: ruby-on-rails rest wicked-gem

你可以在包含WickedWizard gem的控制器中使用非restful方法吗?

控制器:

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和更低版本允许非静态操作,但this commit解决this 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.

我想我应该激发一个新的控制器并将非静止的动作塞进那里,但替代方案会很棒。

1 个答案:

答案 0 :(得分:10)

您需要添加:

skip_before_filter :setup_wizard, only: :waterfall

在邪恶的控制器中