Ruby on Rails #146 Generate Barcodes with JsBarcode. StimulusJS, Importmaps

22/10/2023 (7 months ago)
stimulusjs jsbarcode importmaps

This episode is not what you expected, not what you asked for, and not what you deserve.

Previously, in episode 56, I talked about generating barcodes with gem Barby and storing them in ActiveStorage.

But really, why would you want to STORE a programatically generated file (where the result is always the same)? Why not just generate and display it on the client?

Being a Full Stack Ruby on Rails dev requires sometimes venturing into the JS world; acknowledging that it's easier to do some tasks on the client side. This is one of the cases.

Episode source code: https://github.com/corsego/146-jsbarcode-stimulus-importmaps/commit/d55bbede43fd374cd97d7a2796b609dcaaf57513
Based on this blogpost: https://blog.corsego.com/jsbarcode

0:00 Why use Javascript for Barcodes?
1:35 Auto-generate barcodes for products
3:14 use JsBarcode with importmaps and StimulusJS
6:58 customize the barcode (encoding, size, color)


1
Sign in to join the conversation