When I add the JavaScript library to the Rails resources folder and configure it in the erb file, using: <%= javascript_include_tag('scripts.js') %> , HTML code with classes related to loading the JavaScript file twice.
Here I gave an example here . When I link JavaScript files to a shared folder, this problem does not occur, but JavaScript does not appear instead.
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 corresponding console errors.
Note. This works fine without Rails.
source share