Returning a 1x1 .gif as a response in Rails

Posted by Avishai on Stack Overflow See other posts from Stack Overflow or by Avishai
Published on 2010-05-15T08:50:45Z Indexed on 2010/05/15 8:54 UTC
Read the original article Hit count: 175

Filed under:
|
|

Hi, I'm building a Rails app that does conversion tracking on outside sites. I'd like to allow users to paste an image tag in their conversion pages (like AdWords), and whenever that image is requested, a conversion registers in my app.

respond_to do |format|
  if @conversion.save
    flash[:notice] = 'Conversion was successfully created.'
    format.html { redirect_to(@conversion) }
    format.xml  { render :xml => @conversion, :status => :created, :location => @conversion }
    format.js { render :json => @conversion, :status => :created }
    format.gif { head :status => :ok }
  else
    format.html { render :action => "new" }
    format.xml  { render :xml => @conversion.errors, :status => :unprocessable_entity }
  end
end    

This way, the browser gets a non-existent .gif image. Is there a better way to do this?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about tracking