'$ is not defined error in production environment Rails 5.1.7
jQuery and ujs work fine in the development environment, but are not working in production environment.
This is what my code looks like:
application.html.erb
<html>
<head>
<%= csrf_meta_tags %>
<meta name="viewport" content="width=device-width, initial-scale=1">
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_include_tag 'application' %>
</head>
<body>
<%= yield %>
</body>
</html>
application.js
//= require jquery
//= require jquery_ujs
//= require jquery-ui/widgets/sortable
//= require js-routes
//= require semantic-ui
//= require swiper
//= require cocoon
//= require tree_table
//= require jquery_throttle_debounce
//= require trix
//= require_tree .
window.jQuery = $;
window.$ = $;
Any page that uses the application layout has ujs not working and is getting $ is not defined error for jquery codes in production environment only.
Note: I recently removed turbolinks from the application.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
