Marc Köhlbrugge

Joined

2,460 Experience
21 Lessons Completed
0 Questions Solved

Activity

Thanks for the follow up either way. I think I got it resolved by simply upgrading the sidekiq gem

I'm running into a similar issue right now. ActiveJob/Sidekiq cannot find the record even though it exists. After a retry it does find it.

Did you solve your issue? Curious to hear your findings.

Posted in Realtime Nested Comments: Part 3 Discussion

An individual user will create one consumer-connection pair per browser tab, window, or device they have open. ( source )

Posted in Realtime Nested Comments: Part 3 Discussion

Very cool. I imagine a real-time comment feed like this will make a website feel come alive.

One issue I’d love to see addressed in a follow up video is the page kinda moving around as you’re reading comments. I believe Disqus solves this by not I’m immediately appending new comments, but adding a placeholder like “5 new comments” which you can click to reveal.

I imagine we could do something similar with Stimulus but it right require some changes to the broadcasts.

Posted in Require Work Email Address on Registration Discussion

Once security concern to be aware of when implementing this type of registration system is that many support systems can be abused to receive email on a corporate domain name.

For example, when creating a support ticket with Spotify they might generate a [email protected] email address for your support ticket. You could then use this email address to by sign up to a service that uses the described corporate-email restriction. The confirmation email would be send to the support ticket email address, which you then (as the original Spotify user creating the support ticket) would likely to get notified of. Allowing you to confirm the email address.

The protect yourself from such a hack, make sure to use a special subdomain (e.g. support.spotify.com) for these kind of support ticket emails and code your corporate-email validation such that only root domains (@spotify.com) are allowed. (as described by Chris)

Posted in Improving the Rails Route Generator Discussion

Did you consider automatically generating the sentinel if a pre-existing namespace was used? That way the API of the route method can remain unchanged, but you still solve the issue of having duplicated namespace definitions.

Alternatively a route_namespace method that accepts a block might work to. Something like this:

route_namespace :madmin do
  route …
  route …
end

You can use ruby/setup-ruby's bundler-cache feature to have it take care of installing your gems and caching it. Saves you from adding those steps yourself.

https://github.com/ruby/setup-ruby#caching-bundle-install-automatically

Posted in Nested Comment Threads in Rails - Part 1 Discussion

It sounds like your Comment model doesn't have the commentable_type attribute yet.

Make sure to run your database migrations (rails db:migrate) and try again. If it still gives you the error, then check your database schema file (db/schema.rb) and see if the comments table has a commentable_type column. It probably has not which suggests you need to write a migration that adds it (and potentially the commentable_id column as well).

See the video for how to do this.

Posted in Webpack Bundle Analyzer Discussion

Actually, now that I think about it you might run into issues when adding webpack-bundle-analyzer as just a development dependency. As the webpack config still refers to it.

So if you do want to add it as just a development dependency, make sure to only configure it in config/webpack/development.js

UPDATE:
I was wondering if it still worked with RAILS_ENV=production bin/webpack. It does. That's unexpected, but what we want in this case. There's probably no harm in loading the dependency in production though, so it might be simplest to stick with Chris' approach.

Posted in Webpack Bundle Analyzer Discussion

Thanks Chris. Very timely as I've been trying to optimize my assets.

Two quick suggestions:

  1. You can skip the duplicate BundleAnalyzerPlugin reference by typing this instead:
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
  1. You probably don't need this plugin in production. So you can add it to your devDependencies instead:
yarn add webpack-bundle-analyzer --dev

Chris indeed!

Sorry my bad. I tried subscribing in both NetNewsWire and Feedbin and both said it couldn't find any feed. Rather than asking for a username/password. I now manually added it to the URL and it works 👍

Hi Chris, looks like the RSS link no longer works. Any chance you could add a new one? I often find myself (pleasantly) surprised to see new episodes on the site. Would be nice if we could discover these through our RSS readers as well.

Posted in Searching and partial keyword matches

Hi Chris,

I was searching for the Tailwind + Rails 6 video today, but searching for "Tailwind" did not return it:
https://gorails.com/search?q=tailwind

I eventually did find the episode here:
https://gorails.com/episodes/tailwindcss-1-0-with-rails-6

I think it didn't get included in the search results because the title uses "TailwindCSS" without a space. I imagine your search function looks for whole words only.

Found this! https://github.com/rails/rails/issues/35218#issuecomment-617001327

Let's hope Rails 6.1 will add this.

Hi Chris, I saw your PR related to to_trix_content_attachment_partial_path so I figured you might know this:

Is it possible to specify a partial path for an attachable, without overriding to_partial_path?

I have @mentions implemented in my application just like you show in this video. I use render @user all over the place but that users/_user.html.erb partial is very different from what I'd like the @mentions to look. So I want to specify a different partial path for rendering users within an Action Text.

I could replace my existing render @user specifying a different partial, but that just seems a like hack. I imagine there must be a to_action_text_partial_path-like method somewhere, but I haven't found any yet.

Have a look at this video: https://gorails.com/episodes/notifications-action-text-user-mentions

It shows how to extract the all the mentioned users within an action text to notify them via email. You could do something similar for your tasks. Except in your case it will be tasks instead of users, and instead of sending emails, you create a list of tasks.

For anyone implementing infinite scrolling behavior, I recommend checking out the method used by https://infinite-scroll.com

Instead of using JSON it uses regular HTML pages like you're already used to. No need to modify the controller or create a separate view template. Instead, they fetch the full http://localhost:3000/?page=2 (or whatever), but only use the content inside <div data-target="infinite-scroll.entries"> and append that to the existing div.

I thought it was a clever approach that feels very familiar as it reminds me of Turbolinks. There's very little setup and easy to maintain. With proper caching any performance hit is likely negligible.

I can see the strategy being used with only a slight modification of the code presented in the video.

Thanks. Would love to see an episode on that, as I think most people aren't used to doing Docker Deploys on Heroku.

There are probably ways to do it, but I'd be prefer my CI setup to be self contained. For example I'm using Codeship right now which runs the tests, deploys to Heroku, runs migrations, and checks whether the site is still up.

I'm sure the same is possible with GitHub Actions, but I'm not just not sure how to push to the Heroku git repository from within GitHub.

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.