Rails How to get Javascript working without webpack

22 views Asked by At

I'm running rails 6.1.7.6 and ruby 3.1.1

I'm set up a new rails app on heroku. I tried for two days to get webpack working but I couldn't. I followed many threads, but it kept saying I needed to install the webpack-cli. I had it installed, but the app just wouldn't see it. So I'm trying to get javascript working without it. I followed a couple of threads that said to do these steps:

# app/assets/config/manifest.js

//= link_tree ../images
//= link_directory ../stylesheets .css
//= link_directory ../javascript .js   <-- I added this line

I created an application.js in app/assets/javascript/

# app/assets/javascript/application.js

//
//= require jquery3
//= require jquery-ui
//= require jquery_ujs
//= require turbolinks
//= require_tree
//= require dataTables/jquery.dataTables
//= require activestorage

$(document).ready(function() {
  alert("What the What?");
});
# views/layouts/application.html.erb
# this next line was:

 <%= javascript_include_tag "application", 'data-turbolinks-track' => true %>

The javascript_include_tag causes an error. I read in a thread stating to change this to:

<%= javascript_tag "application", 'data-turbolinks-track' => true %>
# Gemfile:

# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails', '~> 5.0.4'
gem 'jquery-datatables-rails'

But my views do not see my application.js.

Any ideas on how to get this to work?

0

There are 0 answers