rails在destroy之后渲染另一个控制器动作

时间:2012-12-11 15:37:57

标签: javascript ruby-on-rails render

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

这应该呈现一个名为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:

怎么了?

1 个答案:

答案 0 :(得分:3)

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

render action: "/pmdocuments/show"