Skip to content

Instantly share code, notes, and snippets.

@zulhfreelancer
Last active March 28, 2023 07:55
Show Gist options
  • Save zulhfreelancer/fefdb76b863aa26bf76c to your computer and use it in GitHub Desktop.
Save zulhfreelancer/fefdb76b863aa26bf76c to your computer and use it in GitHub Desktop.
How to add jQuery plugin inside Rails project?

Step 1: Download the JS file (example: abc.min.js).

Step 2: Save it inside vendor/assets/javascripts/ folder.

Step 3: To use it inside specific view, put this tag <%= javascript_include_tag 'abc.min' %> inside the view (*.html.erb)

  • And put this inside config/initializers/assets.rb file: Rails.application.config.assets.precompile += %w( abc.min.js )

Step 4: To use it globally inside the Rails app, put this inside application.js file:

//= require abc.min

Step 5: Restart your localhost server to continue working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment