1) What is Ruby on Rails?
Ruby on Rails is a server-side web application development framework written in Ruby language. It allows you to write less code than other languages and frameworks. It includes everything needed to create database-backed web applications according to MVC pattern.
For more information: Click here
2) Explain DRY in Rails?
DRY stands for Don't Repeat Yourself. It is a principle of software development which states that "Every piece of knowledge must have an authoritative, unambiguous, single representation within a system. If same piece of code will not repeat again and again, code will be more maintainable, extensible and less buggy.
For more information: Click here
3) Explain CoC in Rails?
DRY stands for Convention over Configuration. It provides different opinions for the best way to do many things in a web application.
For more information: Click here
4) Who developed Rails?
Ruby on Rails was created by David Heinemeier Hansson (DHH).
For more information: Click here
5) What are the three methods to install Rails?
There are three methods to install Ruby:
- Using rbenv (recommended)
- Using rvm
- From source
For more information: Click here
6) Name some Rails IDE or editor.
Ruby on Rails can be used with either a simple text editor or with an IDE.
Some of the Rails IDEs are listed below:
- TextMate
- Intellij IDEA
- NetBeans
- Heroku
- RubyMine
For more information: Click here
7) What is Rails script and name some of them.
Rails provides us some excellent tools that are used to develop Rails application. These tools are packaged as scripts from command line.
Following are the most useful Rails scripts used in Rails application:
- Rails Console
- WEBrick Web Server
- Generators
- Migrations
For more information: Click here
8) 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.
9) What is Active Record in Rails?
A perfect ORM hides the details of a database's relational data behind the object hierarchy. In Rails, ORM is implemented by Active Record which is one of the most important components of the Rails library.
While using Active Record, you have to no longer deal with database constructs like tables, rows or columns. Your application only deals with classes, attributes and objects.
For more information: Click here
10) Who designed Active Record in Rails?
Active Record is based on a design pattern created by Martin Fowler. From this design pattern only, the Active Record got its name. Its code works very well even with less number of lines. It is quite easy to use. Active Record Rails application does not need any configuration at all, if proper naming schemes is followed in your database and classes.
For more information: Click here
11) Explain model in Rails?
The models are classes in Rails. This subsystem is implemented in ActiveRecord library. This library provides an interface between database tables and Ruby program code that manipulates database records.
For more information: Click here
12) Which command is used to create a migration?
C:\ruby\application>ruby script/generate migration table_name
13) How would you create a controller for subject?
You have to use the following command to create a controller for subject:
C:\ruby\library> ruby script/generate controller subject
14) Explain view in Rails?
View represent data in a particular format in an application for the users. This subsystem is implemented in ActionView library. This library is an Embedded Ruby (Erb) based system which define presentation templates for data presentation.
For more information: Click here
15) Explain controller in Rails?
Controller directs traffic to views and models. This subsystem is implemented in ActionController library. This library is a data broker sitting between ActiveRecord and ActionView.
For more information: Click here
16) Explain RVM in Rails?
RVM stands for Ruby Version Manager. It is a command line tool which allows you to easily install, manage and work with different Ruby environments. With RVM, you can easily install different versions of Ruby and easily switch between them.
Syntax:
The basic syntax of RVM is,
For more information: Click here
17) What are Gemsets in Rails?
Gems in Ruby are used to extend capabilities of core Ruby distribution. They add certain functionalities in programs. Some gems are also installed with Ruby installation to provide certain environments are called gemsets. You can have different versions of same gem installed in a system.
To know all the gems available in Ruby, use following command:
For more information: Click here
18) Write the command to update RVM in Rails.
To upgrade RVM, use following command:
For more information: Click here
19) Explain bundler in Rails.
Rails bundler provides a constant environment for applications by tracking suitable gems that are needed.
To use bundler, use following command:
For more information: Click here
20) Why we use migration in Rails.
Migration alter the database schema for an application in a consistent and oganaized manner by using DSL.
Syntax to create a migration file:
For more information: Click here
21) Write the command to run migration.
For more information: Click here
22) How router work in Rails?
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.
Main purpose of Rails routers is:
- Connecting URLs to code
- Generating paths and URLs from code
For more information: Click here
23) Explain REST in Rails routes.
REST is very useful to understand routes in Rails. It stands for Representational State Transfer. There are several HTTP methods that are used with REST to represent the types of actions performed by the user or application.
For more information: Click here
24) Explain some features of nested scaffolding.
Nested scaffold is the command that generates a set of perfectly working nested resource for Rails 4.2 and 5.
Features
- Generates a nested child resource with a single command
- Generates a beautifully working bunch of code
- Automatically generates appropriate model associations for ActiveRecord
- Haml ready
For more information: Click here
25) In how many ways you can create Rails layout HTTP response.
There are three ways to create an HTTP response from the controller's point of view:
- Call render to create a full response to send back to the browser
- Call redirect_to to send an HTTP redirect status code to the browser
- Call head to create a response to end back to the browser
For more information: Click here
26) Explain importance of yield statement in Rails.
The yield statement in Rails decides where to render the content for the action in layout. If there is no yield statement in the layout, the layout file itself will be rendered but additional content into the action templates will not be correctly placed within the layout.
For more information: Click here
27) How many filters are there in Rails.
Rails filters are methods that run before or after a controller's action method is executed. Rails support three types of filter methods:
- Before filters
- After filters
- Around filters
For more information: Click here
28) How can you protect filter methods in Rails.
All the Ruby methods have at least one of these protection level.
- Public: These methods are accessible from any external class or method that uses the same class in which they are defined.
- Protected: These methods are accessible only within the class in which they are defined and in the classes that inherit from the class in which they are defined.
- Private: These methods are only accessible within the class in which they are defined.
For more information: Click here
29) Explain testing in Rails.
Rails also uses a separate database for testing. Rails uses Ruby Test::Unit testing library. Rails application test is usually run using Rake utility.
Rails basically supports three types of tests:
- functional
- integration
- unit tests
For more information: Click here
30) Explain Rails caching levels.
Rails caching is available at three levels of granularity:
- Page
- Action
- Fragment
For more information: Click here
31) What are Rails validation used for?
Rails validation defines valid states for each of your Active Record model classes. They are used to ensure that only valid details are entered into your database.
For more information: Click here
32) Explain valid? and invalid? in Rails.
The valid? triggers your validations, returns true if no errors are found and false otherwise.
The invalid? is simply the reverse of valid?. It triggers your validations, returns true if invalid and false otherwise.
For more information: Click here
33) Explain Unobtrusive JavaScript in Rails.
"Unobtrusive JavaScript" technique is considered as the best technique within the frontend community.
For more information: Click here
0 comments:
Post a Comment