1
尝试向其他REST风格的控制器添加“发布”动作时,出现“模板丢失 - 缺少模板投票/提交”错误。显然它正在寻找一个submission.html.haml
视图,它不存在(也不应该)。Rails:在非REST风格的动作之后响应REST风格的控制器模板
class BallotsController < ApplicationController
respond_to :html
def index
...
def publish
@ballot = Ballot.find(params[:id])
if @ballot.publishable?
@ballot.submitted = true
flash[:notice] = "Ballot successfully submitted" if @ballot.save
else
flash[:error] = "Could not submit. Ballot incomplete."
end
respond_with(@ballot, location: ballot_url(@ballot))
end
end
我想在这两种情况下在此控制器中的“显示”操作作出响应。但不知道什么语法应该是。