ruby

includes vs. include?: The common misunderstanding

Introduction: In the world of Ruby on Rails and Ruby, two deceptively similar methods, includes and include?, have entirely different roles. This blog post aims to shed light on their differences with concise examples to help you optimize your code effectively. Optimizing Queries with includes: includes is a powerful method in Ruby on Rails. Its…

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…

ruby

Difference Between devise and devise_token_auth

The devise gem and the devise_token_auth gem are both authentication solutions for Ruby on Rails applications, but they serve different purposes. Here’s a brief explanation of the difference between devise and devise_token_auth: Devise: Devise is a popular authentication solution for Ruby on Rails applications. It provides a comprehensive set of features for user authentication, including…

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…