S
S
Stepan2019-11-03 13:19:41
Ruby on Rails
Stepan, 2019-11-03 13:19:41

How to connect js to Ruby on Rails 6?

Outputs in the console:

my.js:8 Uncaught ReferenceError: Bloodhound is not defined
    at Object.<anonymous> (my.js:8)
    at Object../app/javascript/packs/my.js (my.js:136)
    at __webpack_require__ (bootstrap:19)
    at Object../app/javascript/packs/application.js (application.js:22)
    at __webpack_require__ (bootstrap:19)
    at bootstrap:83
    at bootstrap:83

link to Github repo - application.js
Looked in the bundled application.js and my.js is above typeahead.bundle.js (the library that contains Bloodhound). How can I fix this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
N. Bekseitov, 2019-11-04
@nbekseitov

You need to add Bloodhound to the settings of the wepback plugins

environment.plugins.set(
    'Provide',
    new webpack.ProvidePlugin({
        ...
        Bloodhound: 'typeahead.js/dist/bloodhound.js' // полный путь к вашей библиотеке
    })
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question