rails在destroy之后在js中呈现另一个控制器动作

时间:2022-10-29 20:37:50

I'm executing this code in clipsController:

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

This should render a template called show.js.erb located in pmdocuments but instead, I get this error msg:

这应该呈现一个名为show.js.erb的模板位于pmdocuments中,但是我得到了这个错误消息:

ActionView::MissingTemplate (Missing template clips/pmdocuments/show,
application/pmdocuments/show with {:locale=>[:en], :formats=>[:js, :html]
, :handlers=>[:erb, :builder, :coffee, :haml]}. Searched in:

What's wrong?

1 个解决方案

#1


3  

Add a leading /. Its trying to render an action relative to the current controller. So this -

添加领先/。它试图渲染相对于当前控制器的动作。所以这 -

render action: "/pmdocuments/show"

#1


3  

Add a leading /. Its trying to render an action relative to the current controller. So this -

添加领先/。它试图渲染相对于当前控制器的动作。所以这 -

render action: "/pmdocuments/show"