Home > Software design >  after pin local-date still cant use it in time_tag
after pin local-date still cant use it in time_tag

Time:09-10

i go through video of turorial from main page rubyonrails.org, i write in console ./bin/importmap pin local-time in importmap.rb appear:

pin "local-time", to: "https://ga.jspm.io/npm:[email protected]/app/assets/javascripts/local-time.js"

but when i try use it in time tag in post.html.erb:

Posted: <%= time_tag post.created_at, "data-local": "time-ago" %>

appear "Posted: September 09, 2022 10:19" but not "5 minutes ago" or something like this. Basically in projects very simple i just add scaffold post, text rich, here link for it https://github.com/kukla1989/rubyonrails (i will delete it after problem will solve). Sorry if something wrong, i only begin learn rails

i checked 10 times everething like in tutorial, also seems there are no similar problems

CodePudding user response:

You need to import LocalTime in app/javascript/application.js

// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import "@hotwired/turbo-rails"
import "controllers"
import "trix"
import "@rails/actiontext"
// import LocalTime
import LocalTime from "local-time"
LocalTime.start()
  • Related