Stéphane Paquet


2,840 Experience
11 Lessons Completed
2 Questions Solved


I also added a for loop to display the form parameters and their values as console.log does not work in that case.

Using request.js to pass the data to the controller:

import { Controller } from "stimulus"
import { patch } from '@rails/request.js'
import Sortable from "sortablejs"

export default class extends Controller {
  connect() {
    this.sortable = Sortable.create(this.element, {
      group: 'shared',
      animation: 150,
      onEnd: this.end.bind(this)

  async end(event) {
    let id =
    var data = new FormData()
    data.append("position", event.newIndex + 1)

    for (var key of data.entries()) {
      console.log(key[0] + ', ' + key[1]);

    const response = await patch("url").replace(":id", id), { body: data })
    if (response.ok) {
      console.log('Sequence reordered')
    } else {

They are kind of similar. I think that the "main" draw back I've read regarding Papertrail is that it is storing the user ID as a string... so when you do a lookup you have to convert it back to a int.

Did you decide which one to use for your project? If yes, what were you key drivers?

Posted in ViewComponents and Tailwind CSS JIT

found out the change in Tailwind that prevented the expected behavior.

Posted in ViewComponents and Tailwind CSS JIT

I created a flash view component to display flash messages.

It does work, but the javascript trigger its display does not work as expected. Instead of displaying on the spot, it waits for like 5 seconds before rendering and disappear rapidly...

The project uses Hotwire, Stimulus, Webpacker (6), Tailwind CSS 2.2 with JIT

No error reported during the asset compilation but I suspect that the assets are not compiled in the right sequence or something like that.

Here the Stimulus controller code"

import { Controller } from "stimulus"

export default class extends Controller {
  connect() {
    if (!this.isPreview) {
      // Display with transition
      setTimeout(() => {
        this.element.classList.add('transform', 'ease-out', 'duration-300', 'transition', 'translation-y-2', 'opacity-0', 'sm:translate-y-0', 'sm:translate-x-2');

        // Trigger transition
        setTimeout(() => {
          this.element.classList.add('translate-y-0', 'opacity-100', 'sm:translate-x-0');
        }, 100);
      }, 500);

      // Auto-hide after 5 seconds
      setTimeout(() => {
      }, 5000);

  close() {
    // Remove with transition
    this.element.classList.remove('transform', 'ease-out', 'duration-300', 'translate-y-2', 'opacity-0', 'sm:translate-y-0', 'sm:translate-x-2', 'translate-y-0', 'sm:translate-x-0');
    this.element.classList.add('ease-in', 'duration-100');

    // Trigger transition
    setTimeout(() => {
    }, 100);

    // Remove element after transition
    setTimeout(() => {
    }, 300);

  disconnect() {

  get isPreview() {
    return document.documentElement.hasAttribute('data-turbolinks-preview')

Posted in Embed Youtube video in Rails app

Did someone try using video_tag or video.js? I working on a product that needs to display different video sources and having to embed different iframes/players depending on the source is not quite an option.

Check this article looks like it contained the answer to your question.

By default, the helper in Rails looks for the favicons in the assets/images folder. Webpack does not ;-)

Posted in Authentication in 2021

At the same time, owning this data presents risks and add Ops to the project.

Posted in Authentication in 2021

Devise seems to be very popular among the Rails communities and I was wondering why Auth0, Okta, Cognito (AWS) or Firebase, etc. were not that much used to authenticate and manage users in Rails app.

They offer pretty decent free tiers (so developing costs should remain close to 0) and solve a lot of security and compliance issues that we face as developers.

What are your thought and what are your best practices when it comes to user authentication and management?

I cannot agree more regarding the performance improvement. I also think it's a good practice to avoid changing a string that we wanted to be static ;-)

I was wondering if some of you are adding # frozen_string_literal: true to their config files?

Posted in Just sharing: Squash your migrations

Agree. but when testing or launching the app I should have an error about that, pushing me to run the few missing migrations.

After that, I will have a new and up-to-date schema.rb which can be used for all deployment (unless I'm not testing before deploying...)

Posted in Just sharing: Squash your migrations

Thanks Chris for your answer.
I would have thought that the following command rake db:schema:load (likely to berails db:schema:load in modern rails) could be used to quickly setup the database without having to runrails db:migrate, but still preserving the usage of all migration features, especially the option to rollback to any point in time.

Posted in Just sharing: Squash your migrations

2 questions:
How's that different from the schema.rb files ?
Is it compatible with Rails 5.0.x and forthcoming Rails 5.1?

Posted in Anyone with experience using Quilljs?

Thank you @alan and @alex.

Posted in Anyone with experience using Quilljs?


I'm lloking forward using in a project and wonder if anyone can share his/her experience with such text editor.

Related gems are looking pretty outdated (I'm using Rails 5) and connecting Quilljs to a form (I'm using Simple Form) looks akward.


If you are using Devise you can call usersignedin? to determine if a user is or not logged in.

<% if user_signed_in? %>
    Code to display when the user is signed in
<% else %>
    Code to display when the user is not signed in
<% end %>

Posted in Error running Rails with Ruby 2.4.0

@Menj Villalobos this is not an error. It's not blocking your rails app, nor preventing it from starting. This is just a deprecation message.

The question is more to know if Rails 5.0.2 or is going to address this by replace all the Fixnum and Bignum by their new correct type in Ruby 2.4

Posted in macOS sierra working w/ Ruby / Rails / RBENV?

I upgraded and I'm using ruby-install and chruby. So far so good!
If you want to avoid that type of issue, just setup your development environment in a container such as Docker

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.