Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
I have installed webpacker and but rails won't recognise javascript code

I am new to rails and I am making an Instagram clone for practice. For flash messages, I am using toastr-rails gem and javascript code where required But my app is not recognizing javascript script tags and the code is not executing. In the script tag, embedded ruby tags are white colored showing code is not recognized. here is my application.html.erb file code app/views/layouts/application.html.erb

<!DOCTYPE html>
<html>
  <head>
    <title>Instagram</title>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>

    <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
    <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
    <script src="https://kit.fontawesome.com/5238639648.js" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
    <!-- jQuery library -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

    <!-- Latest compiled JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    </head>

  <body>

    <%= render 'shared/navbar' if current_user %>
    <div class="container">
      <%= yield %>
    </div>
    <% if flash.any? %>
      <script type="text/javascript">
        <% flash.each do |key, value| %>
          <% type = key.to_s.gsub('alert', 'error').gsub('notice', 'success') %>
          toastr.<%= type %>('<%= value %>')
        <% end %>
      </script>
    <% end %>

  </body>
</html>

On installing webpacker and adding gem webpacker in my app, nothing happened to my javascript folder as well, like no folder named packs was generated and I did that manually but still, my app won't recognize javascript and files with extension js.erb

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Since, you are using rails 7 which had removed the webpacker as there bundler for JavaScript.

You have to follow manual step to install webpacker. This article has setup guide for webpacker https://www.bootrails.com/blog/rails-webpacker-full-setup/

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!