Mar

Ruby on Rails Interview Questions
- Priyag Chaudhary
- 23rd Mar, 2023
- 818 Followers
Ruby on Rails Interview Questions
Ruby on Rails or Rails is a model-view-controller, server-side framework which is written in ruby. It provides a default structure for a database, web service and web pages. It makes use of web standards like JSON, XML, HTML, CSS, etc. for the transfer of data and also for displaying and user interfacing. It was developed by David Heinemeier Hansson on 13th December 2005. It even uses various software engineering patterns and paradigms some of them being- Convention over configuration (CoC), Don’t Repeat Yourself (DRY), and Active Record Pattern (ARP). It had a great influence on web development since it had some innovative features and frameworks.
Read Top Ruby on Rails Interview Questions and Answers
Following are some interview questions for the ruby on rails framework.
Ruby on Rails Interview Questions
1) Mention all the naming conventions in ruby on rails.
- Variables– it is used for the declaration of variables in which all the letters should be in lowercase and the words should be separated by underscore.
- Class and module– a class is declared which encapsulates every function. The class or module name can be written in mixed case and no underscores are used. Every word should start with an uppercase letter.
- Database table– a table is made for storing the data. It is the same as the naming conventions for variables.
- Model– mixed case is used and have singular with table name.
- Controller– names are represented in plural form.
2) Explain the features of ruby on rails.
- Meta-programming: code generation is used but for heavy lifting, it uses meta-programming.
- Active record: objects are saved to the database through this framework. It identifies the columns in a schema and binds them to your domain object.
- Scaffolding: it means it has the ability of creating temporary code automatically.
- Convention over configuration: much configuration is not needed if the naming convention is followed.
- Three environments: testing, development, and production are the three default environments in this framework.
- Built-in testing: test cases are used in this for writing and executing the codes.
3) How is the model view controller framework used in ruby on rails?
- Model (active record): all the data logic is handled by this model which in rails is known as the active record library. It acts a bridge between the ruby program code and the main database.
- View (action view): the end user sees the view part of the application.
- Controller (action controller): it acts as a data broker of an application. It also helps in handling the logic which allows the model and view to communicate with one another.
This is how the model view controller framework used in ruby on rails.
4) What do you understand by rails?
5) What are the different filters used in ruby on rails?
- Before filters: these filters are executed before the execution of the code in the action controller.
- After filters: these filters are executed after the execution of the code in the action controller.
- Around filters: these are executed both before and after the execution of the code present in the action controller.
6) How can the filter methods in ruby on rails be protected?
- Public: any external class or method that uses the same class in which it is defined can access this method.
- Protected: these can be used only within the class in which they are defined and the classes that inherit from the class in which they are defined.
- Private: these can be accessed only within the class in which they are defined.
7) Explain the role of sub directory app/controllers and app/helpers.
- App/controllers: in this, a web request is made by the user which is handled by the controller. Rails make use of this controller sub directory for finding the controller class.
- App/helpers: some helper classes are present in the helper sub directory which is used for assisting the view, model and the controller classes present in it.
8) What do you understand by rails migration and what it can do?
- It helps in creating the table for the database.
- Dropping the table is possible with the help of this.
- Renaming of the table is possible.
- We can even add columns.
- Renaming of the columns can be done.
- Columns can be changed too.
- We can remove the columns and various other things can be done.
9) Mention the role of rails controller.
10) Mention the differences between the observers and callbacks in ruby on rails.
- Rails observers: these are same as callbacks but are used when the method is not directly associated to the life cycle of the object. It lives for a longer duration of time and can be attached or detached at any time.
- Rails callback: the callback methods can only be called at only certain points of time in the life cycle of an object like validation, creation, updating, deletion, etc. Unlike the rails observers, the rails callback lives for only a short period of time.
Leave A Comment :
Valid name is required.
Valid name is required.
Valid email id is required.