I'm trying to pass params in a controller method's format.html like this:
def create
  @doc = Doc.new(params[:doc])
  respond_to do |format|
    if @doc.save
      format.html { redirect_to share_url(@doc.user.ftp, @doc) }
    else
      format.html { render "new", :locals => { :template => @doc.template_id } }
    end
  end
end
I get a no method error which tells me that I'm sending the right parameter to :template in the local variables:
local_assigns {:template=>4}
Is there something I'm missing to get that to work? It should redirect to the doc#new action but it's going to the doc#index instead. Any ideas?
Using this syntax within a controller:
render "new", :locals => { :template => @doc.template_id }
means that you're rendering the new.html.erb template, not a partial. You are unable to pass local variables along to a non-partial view. What you should be doing is calling render "new", and referring to @doc in that view as you require it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With