lib/jasper-rails.rb in jasper-rails-1.0.0 vs lib/jasper-rails.rb in jasper-rails-1.0.1
- old
+ new
@@ -21,10 +21,11 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
require "jasper-rails/version"
require "rails"
require "rjb"
+require "action_controller/metal/responder"
if Mime::Type.lookup_by_extension("pdf").nil?
Mime::Type.register "application/pdf", :pdf
end
@@ -89,23 +90,23 @@
# Export it!
JasperExportManager._invoke('exportReportToPdf', 'Lnet.sf.jasperreports.engine.JasperPrint;', jasper_print)
rescue Exception=>e
if e.respond_to? 'printStackTrace'
- puts e.message
+ ::Rails.logger.error e.message
e.printStackTrace
else
- puts e.message
- puts e.backtrace
+ ::Rails.logger.error e.message + "\n " + e.backtrace.join("\n ")
end
+ raise e
end
end
end
end
class ActionController::Responder
def to_pdf
- jasper_file = "app/views/#{controller.controller_path}/#{controller.action_name}.jasper"
+ jasper_file = "#{Rails.root.to_s}/app/views/#{controller.controller_path}/#{controller.action_name}.jasper"
params = {}
controller.instance_variables.each do |v|
params[v.to_s[1..-1]] = controller.instance_variable_get(v)
end