0

Hi everyone i've been using rails 7.1.3 and i faced some problem in javascript side where application.js does compile my jquery please if you can help me about that i will be greatfull iv'e been using rails 7.0.5 and i didn't have any issue byt for rails 7.1.3 the application.js the jquery part is not executed thanks enter image description hereenter image description here[enter image description here(https://i.sstatic.net/t6DNL.png)iv'e tried to use script javascript inside html and it's work fine but i need to execute application.js with jquery thanks

8
  • 2
    Don't use images in your question -- idownvotedbecau.se/imageofcode
    – dbugger
    Commented Feb 28, 2024 at 14:09
  • you don't have main.js file to import.
    – Alex
    Commented Feb 28, 2024 at 14:40
  • how can i import main.js thanks for your answer
    – LAX
    Commented Mar 1, 2024 at 10:28
  • where exactly is that file?
    – Alex
    Commented Mar 2, 2024 at 17:23
  • main.js inside custom folder inside javascript folder
    – LAX
    Commented Mar 6, 2024 at 17:55

1 Answer 1

0

You need to pin your files and then import them:

# config/importmap.rb

pin_all_from "app/javascript/custom", under: "custom" 
// app/javascript/application.js

import "custom/main"

https://stackoverflow.com/a/72855705/207090


For jquery, here is how to set it up:

How can I install jQuery in Rails 7 with importmap?

Also, I'd suggest you stop with the inline scripts as well.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.