Rails Tutorial | Building Blog Analytics with Chart.js - Part 2

preview_player
Показать описание

Ruby on Rails makes it quick and easy to build full-stack web applications from the ground up.

👊 Helpful Links 👊

Related episodes:

Other Content:

Рекомендации по теме
Комментарии
Автор

Are there more episodes in this series ? It seems to have stopped at Part 12. It is a great series but there is a lot that was promised but not covered.

tokajak
Автор

I expected this chart to be separated by each post. What should I change to implement this post by post?

jjl
Автор

Hey man, love the videos. I've been following you for a while :)

Just a heads up: You don't need to call `to_a` on your ranges to use an enumerable method on them (i.e. `map`, `each`, etc.) -- You only need to use `to_a` if you literally need the range as an array. All the enumerable methods like `map`, `each`, etc. exist on the Range class just like they do on the Array class.

Probably isn't costing much, if anything, in terms of performance. Just sharing some info -- plus, it looks cleaner :P

Thanks for the vids.

TheRealInky
Автор

When I work with dates I set the default time zone in application.rb like you did, but I don't set to local. So I keep dates in UTC in the postgres database. Then when I set a datetime I do it with *'Time.zone.now.'*
If I want only the date I do it like and I format the date with strftime('%Y-%m-%d') like you did for use in JavaScript.
For all presentation of dates and time in the ui, I use rails methods in I18n, like *<%= l Time.zone.now.to_date, format: :short %>* which returns something like "25 jul" in my language. There are some default formats in I18n, but you can also write your own.
The advantage of using I18n to format date and time is that if your site is multi lingual and you let the user set preferred language, the visitor gets dates formatted to the native way of writing it.

Sorry for the long post. You're doing great work, I learn a lot. Keep it up 👍

TestEchos
Автор

Great episode! I check the Chartkick gem you mention and looks interesting. Can you include in future episodes with Charts the update of dates from "2020-07-24" to "Jul 24" in the Chart. Saludos.

stanmx
Автор

Question for you... I'm trying to build a very similar kind of thing, but using ViewComponentReflex. I have a component to draw a chart using Chartkick/Chart.js, which works great. Then I added links for "group by day | week | month". The reflex works fine, and the active link displays properly, etc. I notice that the chart data is updated as well, so I know that the component is re-rendering properly, however, the chart itself is not redrawn. I did find an example using Chartkick in the SimulusReflex expo, but it uses the afterReflex callback to redraw the chart. I am not aware of a way of actually defining this callback when using ViewComponentReflex (it seems almost like the stimulus controller is "anonymous"). I'm likely doing something wrong, or missing something, but you're the first person I thought of to ask. Any ideas?

TheRealInky
visit shbcf.ru