Created
April 23, 2014 19:01
Revisions
-
Tyler Moore created this gist
Apr 23, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ def show @random = Random.find(params[:id]) respond_to do |format| format.html format.pdf { doc_raptor_send } end end def doc_raptor_send(options = { }) default_options = { :name => controller_name, :document_type => request.format, :test => ! Rails.env.production? } options = default_options.merge(options) options[:document_content] ||= render_to_string ext = options[:document_type] response = DocRaptor.create(options) if response.code == 200 send_data response, :filename => "#{options[:name]}.#{ext}", :type => ext else render :inline => response.body, :status => response.code end end