Issue #1 - 11 - 17 July 2022

Curated code and ideas shared in the second week of July in Ruby world (mostly on Twitter)

General

Ruby and Rails code and ideas

Jim Gay is sharing an example of how to create a class in Ruby:

he also shares how to read the source code of a gem:

Alexandre Ruban shares an excellent way to declare all methods as module functions:

Emmanuel Hayford also replies with the example of using module_function to achieve the same thing:

Nate Berkopec asked about the difference between interned strings (Symbols) and frozen string literals. Jean Boussier has a good and short reply explaining the difference:

Ryan Davis shares a kind of controversy about conditionals in Ruby":

It is worth reading the thread responses.

Steve Polito is sharing an example about setting the job that mailers are calling when using deliver later:

He is also sharing another idea about how to use Devise build-in email regex to validate emails in your own model

Joe Masilotti asked a great question about how to customize controller tests and location when using scaffold generators in Rails.

He received a response from Rafael Franca about using a hook to register a test generator and provided a link to the source where this hook is defined. You should check the whole discussion as it also has some other interesting ideas.

Joel Drapper is sharing some nice code examples about generating static components in the new gem that he is working on Phlex (a new library to create reusable view components). Read the thread as there are some inspiring ideas on how to build chained method calls:

Joel also wrote a good thread about improving the rendering time in views for railsdevs.com. There you will also find a prefetch controller example shared by Julian Rubisch that can be used for prefetching.

CJ Avilla is sharing a great thread about lessons learned while trying to evade a spammer in a Rails 4.2 app. Most of the learnings are valid for any Rails version so it is worth reading it.

Rafal Piekara is explaining in a tweet the difference between .select and .detect in Ruby:

Rob Zolkos recommends executing bin/rails zeitwerk:check in CI environment to check if all classes will load ok:

Shino Kouda is sharing how to use infinity in Ruby:

Samuel Williams is sharing an example of how to inject behavior into an object when a specific method is called:

Emmanuel Hayford is sharing a command that is used to load seeds without rebuilding the database in Rails:

Interesting projects launched by the community:

Robbie Russell is launching an interesting project in the Ruby on Rails recruitment area:

A new Ruby podcast is in the making, created by Julie and Andrew Mason:

Reply

or to participate.