1

Getting "Template is missing - Missing template ballots/submission" error when trying to add a "publish" action to an otherwise RESTful controller. Clearly it is looking for a submission.html.haml view, which doesn't exist (and shouldn't).

class BallotsController < ApplicationController
  respond_to :html

  def index
  ...

  def publish
    @ballot = Ballot.find(params[:id])
    if @ballot.publishable?
      @ballot.submitted = true
      flash[:notice] = "Ballot successfully submitted" if @ballot.save
    else
      flash[:error] = "Could not submit. Ballot incomplete."
    end 
    respond_with(@ballot, location: ballot_url(@ballot))
  end
end

I'd like to respond with the "show" action in this controller in both cases. But not sure what syntax should be.

Meltemi
  • 37,979
  • 50
  • 195
  • 293

1 Answers1

2

I think you can do a redirect_to in there to specify the path:

respond_with(@ballot) do |format|
  format.html { redirect_to ballots_path }
end

(Replace ballots_path with your route.)

ellawren
  • 947
  • 7
  • 16