When I add the JavaScript library to the Rails asset folder and have it configured in my erb file using: <%= javascript_include_tag('scripts.js') %>, the HTML code with the classes associated with the JavaScript file load twice.
I have attached an example here. When I link the JavaScript files to the public folder this issue does not happen, but instead the JavaScript does not show up.
JavaScript
$(function() {
$("a.page-scroll").bind("click", function(a) {
var b = $(this);
$("html, body").stop().animate({
scrollTop: $(b.attr("href")).offset().top
}, 1500, "easeInOutExpo"), a.preventDefault()
})
})
Html.erb
<li>
<a class="page-scroll" href="#portfolio">Portfolio</a>
</li>
<li>
<a class="page-scroll" href="#me">About Me</a>
</li>
<li>
<a class="page-scroll" href="#contact">Contact</a>
</li>
There are no relevant console errors.
Note: This works perfectly fine without Rails.