Posts by adminsrini

class eval and instance eval in Ruby – Meta programming

class_eval class_eval allows us to define a method within the class outside of its original definition and without reopening the...

Includes and joins in active record queries rails.

includes – Uses eager loading and optimally used when accessing each member attributes from the associated records. joins – Uses...

Ruby method lookup

Ruby method lookup

In ruby, which method gets executed when we extend or include it to the class. Which method has more precedence,...

splat (*) and double splat(**) arguments in ruby

Ruby is the flexibility it gives you to do the same thing in many different ways, so you can choose...

How does rails handle CSRF attacks using CSRF token…?

CSRF Stands for Cross Site Request Forgery. First of all, let us know what is a CSRF attack and how...

Difference between _path and _url in rails and when to use them…?

You would have been using redirect_to root_path in your controller action. We also have used redirect_to root_url. So are they...

How to implement Single Table Inheritance in rails

One of the interview questions in Ruby on rails would be What is STI…? How would you implement it…?. But...

Bad Programming practices in rails

1. Not using associations properly Say, we have association of College has many students, having foreign key college_id in student...

Dealing with date and time in rails and how does postgres store datetime

Dealing with date and time in rails and how does postgres store datetime

Every real-time application needs to deal with Date and Time.In rails, Time, Date and DateTime classes reside inside ruby library,...

Why puts and print return nil in ruby?

Why puts and print return nil in ruby?

nil is the Ruby object, not just a keyword, that represents nothingness. Whenever a method doesn’t return a useful value,...