Ruby Method Object, define_method and bind

Ruby methods are executable language constructs. They are not objects. But we can get objects that represents methods with the Object class's method method. Note: This is similar to how blocks are language syntax but not objects in Ruby and we can get object versions of blocks in the forms…

Difference Between Ruby Blocks, Procs, and Lambdas

If you're new to Ruby or if you've been using Ruby for a while but want to understand procs and lambdas a bit deeper, this post is for you. We will look at the Proc object, four ways to create procs and lambdas, see how to invoke them, and look…

How &: Works in Ruby

Chances are you've seen and written code like users.map(&:first_name) in ruby or rails applications many times. If you're new to Ruby, you may have wondered about this strange syntax. Let's demysify &: and explain exactly how it works. First we start with blocks and how to…

What is Arel: Between ActiveRecord and SQL Queries

I recently learned that ActiveRecord uses Arel under the hood. What is Arel? When would it be useful in practice? let's find out! Motivation ActiveRecord is useful and its DSL allows us to write many queries with .find_by and .where. But it does have limitations in the types of…

Stimulus Rails 7 Tutorial

Hotwire (HTML-over-the-wire) ships by default in Rails 7. Stimulus is one component of Hotwire, the other one being Turbo. The key promise of the Hotwire approach is to get the benefits of single-page JavaScript applications like faster, more fluid user interfaces without writing much Javascript (certaintly not the amount needed…

Introduction to Hotwire and Turbo

The Rails 7 release in December 2021 officially shipped with Hotwire. Or more precisely with the turbo-rails and turbo-stimulus gems. Hotwire is an 'umbrella' term for the concept of sending Html-Over-The-wire but not a specific library. Although I started working with Ruby and Rails in 2012 when I transitioned doing…

Boron Letters: Advice on Copywriting - Part 7

Chapter 24 Getting customer's attention Reasons for stopping a habit, in this case of writing letters: he wants to review some reference material and take notes to have more coherent things to write he wants the son to type up the first 25 letters he is going to focus on…

Boron Letters: Advice on Copywriting - Part 6

Chapter 21 How to think about offering a product discount The author is feeling tired. Physically in terms not being able to complete his 'road work' in one go. And also mentally in terms of longing for freedom and feeling down in general. Yet the writing continues. [Lesson] The author…