Interviewer And Interviewee Guide

Role-specific Ruby on Rails Developer Interview Questions & Answers:

1. What is Rails Router?

The Rails router recognizes URLs and dispatches them to a controller's action. It also generate paths and URLs. Rails router deals URLs in a different way from other language routers. It determines controller, parameters and action for the request.

2. Tell us what is the use of super function in Ruby on Rails?

The super function in Ruby is used to invoke the original method. It calls the super class implementation of the current method.

3. Tell us what's the difference between new, save and create?

new – makes a new object but doesn't save it to the database
save – saves the model. If the model is new a record gets created in the database, otherwise the existing record gets updated.
create – makes a new object and saves it to the database in one go

4. Tell us what are benefits of using Active Record as opposed to raw SQL queries?

Here are the benefits:

☛ it's really easy to go wrong during writing SQL queries
☛ each different type of database usually has a slightly different flavour of SQL, so it could be really painful if, during work on a big app, you decide to switch to a different database
☛ using Active Record reduces code significantly and makes it easier to read
☛ using Active Record makes common operations simpler and easier than writing your own SQL statements

5. Explain me what is Testing in Rails?

Rails test is very simple to write and run for your application. As Rails script generates models and controllers, in the same way test files are also generated. Rails also uses a separate database for testing. Test database in an application is rebuilt each time the application's test run, and hence you always have a consistent database when your tests are run.

6. Do you know the role of the subdirectories app/controllers and app/helpers in Rails?

The app/controllers subdirectory holds all the controller classes for the app. Controllers handle web requests from the user. The app/helpers subdirectory holds helper classes, which are used to assist the model, view, and controller classes. By keeping helper classes in a separate subdirectory, the model, view, and controller classes can remain lean and uncluttered.

7. Do you know what is Rails Caching?

Caching is used in any web technologies. It speeds up the performance by storing previous results for subsequent requests. By default, cahcing is disabled in Rails.

Rails caching is available at three levels of granularity:

☛ Page
☛ Action
☛ Fragment

8. Please explain what is the purpose of the rakefile available in the demo directory in Ruby?

The purpose of this simple question is to make sure a developer is familiar with a test-driven development. A beginner may not have dealt with this file yet. The rakefile is similar to the makefile in Unix, and assists with packaging and testing Rails code. It's used by the rake utility, which ships natively with the Ruby installation.

9. Explain me what Are The Servers Supported By Ruby On Rails?

RoR was generally preferred over WEBrick server at the time of writing, but it can also be run by:

Lighttpd (pronounced ‘lighty') is an open-source web server more optimized for speed-critical environments.

Abyss Web Server- is a compact web server available for windows, Mac osX and Linux operating system. Apache and nginx

10. Do you know what are rails filters?

Rails filters are methods that run before or after a controller's action method is executed. They are helpful when you want to ensure that a given block of code runs with whatever action method is called.

Rails support three types of filter methods:

☛ Before filters
☛ After filters
☛ Around filters

Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.