How to implement your own Struct class in Ruby? Metaprogramming in Ruby, part 2.

You probably already know Ruby class Struct. It allows you to create a simple class with the properties that were passed as arguments to its initializer. Also, it will run a block that was passed to its initializer within the newly created class'es scope thus allowing you to define methods, etc. Let's try to implement … Continue reading How to implement your own Struct class in Ruby? Metaprogramming in Ruby, part 2.

Metaprogramming in Ruby, part 1

I decided to challenge myself to write code similar to what can be found in every Rails application.rb file. TestApp::Application.configure do # Settings specified here will take precedence over those in config/application.rb # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned on config.consider_all_requests_local = … Continue reading Metaprogramming in Ruby, part 1

Dynamically fading flash messages in Vue.js and VueX

We will be creating dynamcally fading flash messages with Vue.js and VueX. Let's say you want to display a flash message on a certain condition and you want that flash to show only for a couple of seconds and disappear afterwords. It is very easy to implement it yourself within a minute without any 3rd … Continue reading Dynamically fading flash messages in Vue.js and VueX

How to implement Rails params from the ground up in Ruby?

Hi guys! This time around I am going to show you how to implement Rails params completely from the ground up. As you probably already know, Rails has something called strong parameters. This is a security practice to prevent accidentally allowing users to update sensitive model attributes, for example "admin" flag in user model in … Continue reading How to implement Rails params from the ground up in Ruby?