ruby

Checking Null or empty values in Ruby

n Ruby, you can easily check whether a variable is nil or an empty value for different data types, including strings, arrays, and hashes. Here are some common ways to perform null and empty checks: Checking for nil Checking for Empty Strings Checking for Empty Arrays Checking for Empty Hashes Using blank? In Ruby, the…

Interview Experience

Interview Experience at DirectShift for Senior Fullstack Developer Role

DirectShifts has set out to modernize healthcare recruiting. Introduction DirectShift specializes in healthcare professional recruitment and develops software in this domain. I had the opportunity to interview with them for the position of Senior Fullstack Developer at their Pune location. I was connected directly to the HR team through a referral. Round 1: Referral System Project…

ruby

Drawbacks of Active Record

Active Record is a pattern used in software engineering that represents the database in an object-oriented manner. In other words, it’s a way to use objects to interact with a database instead of writing SQL queries directly. In Ruby on Rails, Active Record is the default ORM (Object-Relational Mapping) that allows developers to define database…

ruby

Ruby on Rails object lifecycle and callbacks

In ROR, the lifecycle of an object is attached to the database of the application. Objects are created in memory first then later stored in the database. An object have following lifecycle Creation Validation Save Update Deletion These lifecycle have callbacks attached to each of them by which we can inject our custom logic. Creation…

ruby

Functions in Ruby that make life easy.

I have been using ROR for the last eight months and started loving this language because of the poetic way it allows me to write the code. In this journey, I have found some functions which helped me to keep the code short and improved readability significantly. 1. blank? and present? A common use case…

ruby

Reload in ruby and when to use it.

Consider we have a model student when we access data from this using the following command. The variable student contains the data of a student. Each student has enrolled in many courses, which is another model. On printing the student, we get the following data Consider if I update the course model, The expected behavior…

Tech

with_options in rails

I have recently encountered this method, which saved my time and helped me follow the DRY principle Use case: Consider a scenario, you have a list of trains and you have to apply filters on like depature_time, arrival_time, train_number, arrival_station, depature_station, number of coaches, etc. For that, you have to write interaction. The input will…