Georg Ledermann PRO
Joined 5/9/2016
Full Stack Web Developer
Georg Ledermann PRO said almost 7 years ago on Upgrading Ruby on Rails Versions :

Nice website for doing the diff:

http://railsdiff.org/4.2.10/5.0.0


Georg Ledermann PRO said almost 6 years ago on What the RegEx? :
Worth mentioning: https://rubular.com/

Georg Ledermann PRO said almost 3 years ago on Infinite Scrolling with Hotwire :
The first drawback of the no-JS approach can be mitigated by this code in the controller:

class PostsController < ApplicationController
  ...  
  def index    
    respond_to do |format|
      format.html
      format.turbo_stream { @pagy, @posts = pagy_countless(Post.all) }    
    end  
  end
  ...

It ensures that posts are loaded for turbo_stream requests only.

Georg Ledermann PRO said almost 2 years ago on Push Notifications from Scratch :
Great episode, but while playing with the repo, I get an error in the browser console within Safari 16.3 on MacOS 13.2.1 and the notification does not work:

Notification prompting can only be done from a user gesture.

In other browsers (tested with Edge) there is just a warning, and the notification is displayed.

The error comes from startServiceWorker on the next visit after the notification was allowed. I changed the method (by removing the call of requestNotificationPermission()) to this and now it works fine:

async function startServiceWorker() {
  const vapidPublicKey = document.head
    .querySelector('meta[name="vapid_public_key"]')
    .getAttribute('content');
  await registerServiceWorker();

  const subscription = await getPushSubscription(vapidPublicKey);
  if (!subscription) return;

  await sendSubscriptionToServer(subscription);
}