Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

238
Vistas
rails 6 WebPack is not loading javascript in content_for
Uncaught ReferenceError: $ is not defined

I'm getting the above error for all those javascripts which are called/declared inside the views. It gives Uncaught ReferenceError: $ is not defined when it renders that specific view, while Jquery works fine for normal JS files.

for example, taking the following view company.html.haml in consideration, it gives error at companyUpdates.initializeDashboardList(indexParams, '111','basic');

any idea, how i can run all those javascript calls present in the ruby on rails application views ?

company.html.haml

.section-content#dashboard-intelligence
  .section-header
    == Heading

- content_for :additional_js do
  :javascript
    indexParams = { appId: "111", key: "111", name: "hello" }

    $(document).ready(function(){
      companyUpdates.initializeDashboardList(indexParams, '111','basic');
     });

Custom.js

const webpack = require('webpack')
module.exports = {
     resolve: {
        alias: {
            $: 'jquery/src/jquery',
            jquery: 'jquery/src/jquery',
            React: 'react',
            ReactDOM: 'react-dom'
          },
       fallback: {
         "punycode": require.resolve("punycode/")
        },
       extensions: ['.jsx']
     },
   plugins: [
      new webpack.ProvidePlugin({
      $: "jquery",
       jQuery: "jquery",
       React: 'react',
       I18n: 'i18n-js'
    }),
  ]
 }

base.js

const { webpackConfig, merge } = require('@rails/webpacker')
const customConfig = require('./custom')
module.exports = merge(webpackConfig, customConfig)

development.js

 process.env.NODE_ENV = process.env.NODE_ENV || 'development'
 const webpackConfig = require('./base')
 module.exports = webpackConfig

environment.js

This is an empty file 
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda