Search code examples
javascriptruby-on-railsrubyunobtrusive-javascript

Including Javascripts hosted on localhost in a rails app


I have a page app/views/shared/_tcpsocket.html.erb and am trying to include the following two javscripts:

<script src = 'http://localhost:8000/static/Orbited.js' content-type='application/x-javascript'></script>

and

<script src = 'http://localhost:8000/static/protocols/xmpp/xmpp.js' content-type='application/x-javascript'></script>

But neither of them are recognised. I have checked and the addresses are valid. How do I link to these files? Do I need a javascript_include_tag? I always seem to struggle linking to external .js files.

Thanks.


Solution

  • Why are you putting spaces between the src, = and value for this attribute? Try not putting these spaces there and see what results. I believe that HTML is parsing each space-separated value as its own attribute.