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?
This seems to be a simpler solution
Source:
http://forrst.com/posts/Render_a_1x1_Transparent_GIF_with_Rails-eV4
instead of rendering, call
send_data(Base64.decode64("R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="), :type => "image/gif", :disposition => "inline")
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