ndemoreau
ndemoreau

Reputation: 3869

rails render another controller action in js after destroy

I'm executing this code in 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:

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?

Upvotes: 0

Views: 885

Answers (1)

Scott S
Scott S

Reputation: 2746

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

render action: "/pmdocuments/show"

Upvotes: 3

Related Questions