Rails: migrating from sprocket to webpacker

Viewed 134

hi I'm having difficulty migrating my app from rails 5 using sprockets to rails 6 using webpacker. I am using global variables as seen in my code but I've read rails 6 with webpacker does not like this.

root.html.erb

<% if logged_in? %>
  <script id="bootstrap-current-user" type="text/javascript"> 
    window.currentUser = <%= render("api/v1/users/user.json.jbuilder", user:current_user).html_safe %>
  </script>
<% end %>

I'm wondering what solutions you have implemented to be more compatible with webpacker. Thank you

0 Answers
Related