我正在 ClipsController 中执行此代码:
def destroy
@clip = Clip.find(params[:id])
@clip.destroy
respond_to do |format|
format.html {redirect_to request.referer, notice: "Attachment deleted."}
format.js {
@pmdocument = @clip.attachable
render action: "pmdocuments/show"
}
end
end
这应该呈现位于 pmdocuments 中名为 show.js.erb 的模板,但我收到此错误消息:
ActionView::MissingTemplate (Missing template clips/pmdocuments/show,
application/pmdocuments/show with {:locale=>[:en], :formats=>[:js, :html]
, :handlers=>[:erb, :builder, :coffee, :haml]}. Searched in:
出了什么问题?
最佳答案
添加前导/
。它试图呈现相对于当前 Controller 的 Action 。所以这个 -
render action: "/pmdocuments/show"
关于javascript - Rails 在销毁后在 js 中渲染另一个 Controller 操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13823235/