Tutorials
How to Dynamically Create Instance Variables in Ruby
This post shows one way to dynamically initialize multiple instance variables in a Ruby class using metaprogramming. If you need to pass multiple, separate pieces of data to a constructor (and cannot refactor the code for some reason), it's a pret...
Rails 7.1 adds routes --unused option to detect extraneous routes | Shakacode
Discover extraneous routes in your Rails application effortlessly by utilizing the --unused option with the rails routes command.Rails routes are essential for mapping URLs to specific actions, controllers, and views in your application. As your R...
Safeguarding From Deprecation Regressions During an Upgrade
You are upgrading a Rails application. You finished fixing a deprecation warning and it’s not present anymore. You continue working on other tasks and one day you find out the deprecation is back in the codebase. New code was added using the depre...
Seed your database with the Faker gem. Then seed 9.4x faster with upsert_all and activerecord-import.
I cover 3 things in this article —Using the faker gem in a Rails app to seed 10,000 fake records.Fixing our slow seeds by making them 9.4x faster, using upsert_all or the activerecord-import gem (since our naive method is very inefficient).Finally...