Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add js scripts in the application.html.erb

I am new to rails, I know that we add our css and js files in application.html.erb file.

But do we also add the js scripts in the same file?

For example this script below

   <script>
    $(function () {
      $("#slider").responsiveSlides({
        auto: true,
        speed: 500,
        namespace: "callbacks",
        pager: true,
      });
    });
  </script>
like image 537
Suraj Shukla Avatar asked Sep 03 '26 06:09

Suraj Shukla


1 Answers

You can add any scripts in application.html.erb, but i think will be better to require application.js in application.html.erb with javascript_include_tag:

<%= javascript_include_tag "application" %>

and include any scripts from javascript folder in application.js

//= require library_name

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!