1

I'm working on Rails layout for pdf (using Pdfkit) and I need to include my javascript assets with absolute paths (full urls) because wkhtmltopdf doesn't see relative.

this:

= javascript_include_tag 'application'

is converted to this:

<script src="/assets/jquery.js?body=1"></script>
<script src="/assets/jquery_ujs.js?body=1"></script>
<script src="/assets/jquery.ui.core.js?body=1"></script>
<script src="/assets/jquery.ui.widget.js?body=1"></script>
<script src="/assets/jquery.ui.position.js?body=1"></script>
<script src="/assets/jquery.ui.menu.js?body=1"></script>
<!-- MUCH MORE :) -->

How can I get the same script tags with full urls?


// edit

= (javascript_include_tag 'application').gsub('="', "=\"#{ root_url }").html_safe
Eyeslandic
  • 14,553
  • 13
  • 41
  • 54
ciembor
  • 7,189
  • 13
  • 59
  • 100

2 Answers2

0

This should work

javascript_include_tag('application').delete("\n").gsub('="', "=\"#{ root_url }")
Wally
  • 61
  • 6
-1

I think it will be the best solution for this case

<%= javascript_include_tag 'application', host: request.base_url %>