rails-timeago icon indicating copy to clipboard operation
rails-timeago copied to clipboard

Usage Rails 8 and Importmaps

Open rip747 opened this issue 8 months ago • 0 comments

Has anyone has any luck getting this plugin to work with Rails 8 and using Importmaps?

I am getting the following error:

Uncaught ReferenceError: jQuery is not defined

I can see that the timeago_script_tag is outputting correctly

//<![CDATA[
jQuery.timeago.settings.lang="en";
//]]>
</script>

My config/importmap.rb has the following:

Pin npm packages by running ./bin/importmap

pin "application" pin "@hotwired/turbo-rails", to: "turbo.min.js" pin "@hotwired/stimulus", to: "stimulus.min.js" pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" pin_all_from "app/javascript/controllers", under: "controllers" pin "jquery" # @3.7.1

and in my layout header I have the following

<%= javascript_importmap_tags %> <%= javascript_include_tag "application", type: "module" %> <%= timeago_script_tag %>

Is there something else that i'm missing?

rip747 avatar May 07 '25 18:05 rip747