繁体   English   中英

Rails销毁后在js中呈现另一个控制器动作

[英]rails render another controller action in js after destroy

我在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:

怎么了?

添加前导/ 它试图呈现相对于当前控制器的动作。 所以这 -

render action: "/pmdocuments/show"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM