【发布时间】:2014-01-14 14:38:10
【问题描述】:
您能否在包含 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
版本 1 及更低版本的 gem 允许非 restful 操作,但 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.
我想我应该启动一个新的控制器并将非安静的操作塞进去,但替代方案会很棒。
【问题讨论】:
-
由于问题与gem的特性/bug有关,我认为最好直接向gem提交问题或PR,以便更快地获得帮助。
-
Weeell,我感觉有点糟糕,因为我可能应该保持 RESTful。这是我的缺点,而不是宝石,真的。
-
我不熟悉这颗宝石。但是在某些情况下仍然需要不平静的东西。也许维护者对此有更好的看法。
-
我相信
Wicked使用id来检索步骤,因此检查steps数组是否包含show操作中传递的id,然后进行相应的渲染可能是一种选择。 -
哦,我喜欢。 Ta -- 我稍后再报告。
标签: ruby-on-rails rest wicked-gem