If you’re looking for Ruby On Rails Interview Questions for Experienced & Freshers, you are in the right place. There are a lot of opportunities from many reputed companies in the world.
Ruby On Rails Interview Questions For Freshers
1) Explain what is Ruby on Rails?
Ruby: It is an object-oriented programming language inspired by PERL and PYTHON.
Rails: It is a framework used for building a web application
2) Explain what is class libraries in Ruby?
Class libraries in Ruby consist of a variety of domains, such as data types, thread programming, various domains, etc.
3) Mention what is the naming convention in Rails?
Variables: For declaring Variables, all letters are lowercase, and words are separated by underscores
Class and Module: Modules and Classes uses MixedCase and have no underscore; each word starts with an uppercase letter
Database Table: The database table name should have lowercase letters and underscore between words, and all table names should be in the plural form for example invoice_items
Model: It is represented by unbroken MixedCase and always have singular with the table name
Controller: Controller class names are represented in plural form, such that OrdersController would be the controller for the order table.
4) Explain what is “Yield” in Ruby on Rails?
A Ruby method that receives a code block invokes it by calling it with the “Yield”.
5) Explain what is ORM (Object-Relationship-Model) in Rails?
ORM or Object Relationship Model in Rails indicate that your classes are mapped to the table in the database, and objects are directly mapped to the rows in the table.
6) Mention what the difference is between false and nil in Ruby?
In Ruby False indicates a Boolean datatype, while Nil is not a data type, it have an object_id 4.
7) Mention what are the positive aspects of Rails?
Rails provide many features.
Rails use code generation but for heavy lifting, it relies on meta-programming. Ruby is considered one of the best languages for Meta-programming.
It saves the object to the database through the Active Record Framework. The Rails version of Active Record identifies the column in a schema and automatically binds them to your domain objects using metaprogramming
Rails have an ability to create scaffolding or temporary code automatically
Convention over configuration
Unlike other development framework, Rails does not require much configuration, if you follow the naming convention carefully
Rails come with three default environment testing, development, and production.
It supports code called harness and fixtures that make test cases to write and execute.
8) Explain what is the role of sub-directory app/controllers and app/helpers?
App/controllers: A web request from the user is handled by the Controller. The controller sub-directory is where Rails looks to find controller classes
App/helpers: The helper’s sub-directory holds any helper classes used to assist the view, model and controller classes.
9) Mention what is the difference between String and Symbol?
They both act in the same way only they differ in their behaviors which are opposite to each other. The difference lies in the object_id, memory and process tune when they are used together. Symbol belongs to the category of immutable objects whereas Strings are considered as mutable objects.
10) Explain how Symbol is different from variables?
The symbol is different from variables in the following aspects
It is more like a string than variable
In Ruby string is mutable but a Symbol is immutable
Only one copy of the symbol requires to be created
Symbols are often used as the corresponding to enums in Ruby
I hope the above interview questions help you to get a job.
For next 10 Rails Interview questions and Answes Click hear for Part 2