Ruby and Ruby on Rails interview questions



Hello friends in this post I will daily add one new interview question related to Ruby or Ruby on Rails so please bookmarked this post because here you will find all the possible interview questions related to Ruby and Ruby on Rails.

Que 1- What is the difference in == and === in Ruby?
Ans: == is used to compare the equality of two object.
Example a = 5, b = 6
puts a == b //output false
puts a == 5 //output true

In other hand === is used to check if given number or character is included in particular range.
Example nums = 1..50
puts nums === 25 //output true
puts nums === 66 //output false

Qus 2- Difference in form.select and select_tag in rails ?
Ans- Here is the syntax of form.select

<%= form.select :topic_id, options_from_collection_for_select(Topic.all, 'id', 'title', @blog.topic_id),{}, {class: "form-control"} %>

Here is the syntax of select_tag

<%= select_tag "blog[topic_id]", options_from_collection_for_select(Topic.all, "id", "title", @blog.topic_id), {class: "form-control"} %>