Categories

Blog categories

Ruby on Rails

Sub Categories


Ruby on Rails is s continuously evolving web framework. Here we discuss the importance and advantages of frequently upgrading the framework.

Blog Posts


Posted by Ziyan Junaideen 24 October 2022
Fix Library not loaded: /usr/local/lib/libpq.5.4.dylib error after you upgrade your Homebrew packages.
Posted by Ziyan Junaideen 25 November 2021
Enable Tailwind CSS with JIT in your Ruby on Rails project using the new `cssbundling-rails` ruby gem. Includes advice for Trailblazer configuration.
Posted by Ziyan Junaideen 21 October 2021
Managing the database through Ruby on Rails and ActiveRecord is intuitive. Learn commonly used data types in AR for PostgreSQL, MySQL, SQLite, Oracle & SQLServer with special data types for PG.
Posted by Ziyan Junaideen 11 April 2021
A photo is worth a thousand words, how much does a video worth? Including videos as intros and backgrounds are becoming common and with HTML5 we can do so without the use of any plugins.
Posted by Ziyan Junaideen 17 October 2021
Learn how to use SQL CASE statements to conditionally sort a dataset by either mapping a column value to another value or using a column value to decide which column value to sort by.
Posted by Ziyan Junaideen 08 June 2021
Bundling foreman with Ruby applications is a bad practice some Ruby developers practice this date. This needs to stop and here is why. Long story short, read the documentation people!
Posted by Ziyan Junaideen 27 April 2021
Serve responsive and retina images in a Ruby on Rails application without 3rd party library or any additional code just using the `srcset` property in the `ActionView::imgae_tag` helper.
Posted by Ziyan Junaideen 04 October 2021
Check to confirm file attachment is common with any file upload implementation. This is how you can confirm that a modal with CarrierWave has indeed a file attachment. Includes "good practice", "bad practice" and what doesn't work.
Posted by Ziyan Junaideen 19 August 2023
UUID v7 overcomes the limitations of v4 by including an 48 bit epoch timestamp along side random data. Here we discuss how you can enable UUID v7 on PostgreSQL and use it on a Ruby on Rails project.
Posted by Ziyan Junaideen 23 November 2021
A collection of test cards for the popular card processor USAePay as their official support page is out of date (expiring 0921). These cards and their details are valid through 2023.
Posted by Ziyan Junaideen 24 September 2021
The Cookie Consent prompt negatively affects the effectiveness of landing pages. I recommend you disable them unless necessary. This is how you can disable sessions on routes on your Rails website.
Posted by Ziyan Junaideen 13 April 2022
A little advice from my encounter with the LinkedIn Skill Assessment Test for Ruby on Rails. It is an easy test and any Rails developer could easily land on a new shiny badge.
Posted by Ziyan Junaideen 18 May 2022
If you are testing RoR mailer views using RSpec and FFaker gem, you could randomly experience match failures. This post explains how you can use HTML escape to bring escape the name before matching.
Posted by Ziyan Junaideen 08 June 2021
Foreman is a tool commonly used in application development environments to manage applications based on Procfiles. I experienced a Rails application freeze when used inside foreman and the fix was to use `bundle exec`.
Posted by Ziyan Junaideen 29 January 2022
Fix port 5432 connection refused error in macOS caused by Homebrew failure to start PostgreSQL database engine.
Posted by Ziyan Junaideen 31 October 2021
The resque-scheduler is an integral part of most legacy Ruby on Rails applications that use Resque. When upgrading such projects you might experience an error related to rufus-scheduler.
Posted by Ziyan Junaideen 25 December 2021
The software world evolves rapidly, and it is essential to track outdated libraries to update them. This blog post discusses identifying and listing libraries that could be updated using Bundler (Ruby) and Yarn (Node), as many web projects include Node dependencies.
Posted by Ziyan Junaideen 27 October 2021
An error was encountered while upgrading a Ruby on Rails 3.2 app related to a migration to create a PostgreSQL integer array. Updating the migration to modern syntax fixed the issue.
Posted by Ziyan Junaideen 21 May 2021
The days of out of date secrets.yml files are over. Welcome, RoR encrypted credentials where you can encrypt and safely store credentials along with the source code. This is how you can activate it in Rails 5.1.
Posted by Ziyan Junaideen 07 October 2022
VCR is a tool that can be of immense help for developers testing against 3rd party APIs. This post discusses how to track down unused VCR cassettes for remvoal.
Posted by Ziyan Junaideen 03 April 2021
It could be argued that `NOT NULL` is the most popular database constraint out there. There are times you need to add a constraint or remove it. Some advice on how to do it in Ruby on Rails.
Posted by Ziyan Junaideen 11 March 2023
Not everyone has the luxury of having a beefed-up MacBook. I have wondered if 8GB of RAM will be sufficient for my work, and the answer is yes. But I do recommend at last 16GB.
Posted by Ziyan Junaideen 27 March 2022
With the introduction of ActionCable with Rails 5.0, WebSockets are now first-class citizens in the Ruby on Rails ecosystem. This article is an introduction to the WebSockets implementation in Rails.
Posted by Ziyan Junaideen 21 October 2021
Learn how to use the Encryptor gem directly to encrypt and decrypt data on Ruby applications to keep sensitive data secure and have the flexibility to handle encrypted output as you see fit.
Posted by Ziyan Junaideen 11 May 2022
Fix the error when bundle install of a Ruby on Rails project w.r.t. nio4r. The issue generally is the result of implicit function declaration causing errors compiling native C extensions.
Posted by Ziyan Junaideen 06 June 2022
The "NSCFConstantString initialize error" bugged me right after a macOS Monterey installation on a Ruby on Rails v7 project. The solution is quick and simple. Why it happens though is a curious matter I would leave for later.
Posted by Ziyan Junaideen 25 November 2021
The static declaration of width and height makes YouTube video embed links not mobile responsive. This blog post describes a JS solution to make videos mobile responsive.
Posted by Ziyan Junaideen 02 April 2022
Not every model/database table requires an auto-increment integer field as the primary key. Ruby on Rails allows us to specify the primary key in the migration field and configuration in the model.
Posted by Ziyan Junaideen 11 March 2022
Bring life to your Rails application by using Toastr alerts with Turbo and Stimulus JS. This blog post details the steps with code samples to show Toastr flash messages.
Posted by Ziyan Junaideen 27 March 2022
Caching is a vital instrument to reduce the load on the server and deliver reused results and speed up page load for the user. Rails 5 introduces collection caching that can vastly improve performance.
Posted by Ziyan Junaideen 29 May 2022
Enums are a useful and commonly used data type in Ruby applications. Rails 7 introduces support to create native PG enum data types. This post discusses the creation and use of native enums with PostgreSQL, advantes & disadvantages.
Posted by Ziyan Junaideen 25 June 2023
Introduction to RSpec Request Specs and how you can use it in your Ruby on Rails application.
Posted by Ziyan Junaideen 22 May 2021
Tutorial on how you can set HTML attributes dynamically when writing views using the popular HTML abstraction markup language HAML.
Posted by Ziyan Junaideen 12 January 2023
Rswag is a useful tool when it comes to documenting an API that is both OpenAPI and Swagger compatible. Here we discuss how we can work around unsupported attributes like servers.
Posted by Ziyan Junaideen 13 April 2022
Those who enjoyed the where.not(...) query method will surely find the query.invert_where query method a welcoming feature. It allows us to easily invert entire queries.
Posted by Ziyan Junaideen 13 April 2022
Learn how you can track an ActiveRecord objects attribute changes across its lifecycle or page request. The methods [attr]_was, [attr]_chagned?, [attr]_previously_was are some among the helpful methods implemented in ActiveModel::Dirty module.
Posted by Ziyan Junaideen 13 April 2021
Generating darkened and lightened colors based on a given colour is common in web interface development. This are the options you have to generate darkened and lightened colours in Ruby on Rails.
Posted by Ziyan Junaideen 28 March 2022
The popular Ruby on Rails library ActsAsTaggableOn wrongfully selects the parent class in STI resulting empty #tagged_with method output. The solution would be to use a custom query.
Posted by Ziyan Junaideen 02 November 2021
Some rumors have been going around that Ruby on Rails is dead. Rails are doing better than I expected and I would definitely recommend new developers and clients to look at Rails.
Posted by Ziyan Junaideen 02 April 2021
The popular Trailblazer sister project Reform (and Reform-Rails) on Ruby 3.0 environment is expected to have errors due to the fact Ruby 3 is not yet supported. Updates expected to come soon.
Posted by Ziyan Junaideen 30 March 2021
Fix the JavaScript error "Lqb is not defined" where it works in Development but not in Staging or Production environments (where assets are compiled and minified).
Posted by Ziyan Junaideen 29 April 2023
DRY your test code by generalizign repetitive tests in to RSpec shared examples.
Posted by Ziyan Junaideen 28 March 2022
Ruby on Rails doesn't add model field details to the model and related files such as specs and factories. The annotate library automatically adds field definitions to relevant files.
Posted by Ziyan Junaideen 24 May 2021
Fix the error "There is a chance you are experiencing a man-in-the-middle attack" you get running bundle install in an ancient Rails project rocking Rails Assets.
Posted by Ziyan Junaideen 08 December 2021
Opening a file to read its contents is common in any application. The introduction of the method "existence" enables us to use Ruby Safe Navigation Operator to check for existence and safely read file.