Total Blog Views: 42
Blog Status: publish
Created By: swazahmad Created at: 07-14-2021
Tags: web development software engineering ruby rails ruby on rails interview questions rails
1) What is Ruby on Rails?
Ruby: It is an object oriented programming(OOPS) language inspired by PERL and PYTHON.A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.
2) Explain what is class libraries in Ruby?
Class libraries in Ruby consist List of domains below
3) What naming conventions follow in Rails?
Variables: For declaring Variables, all letters are lowercase, and words are separated by underscores
ex. first_name, last_name
Example: StudentClass
ex. StudentRecord
4) Explain what is “Yield” in Ruby on Rails?
Yeild is a ruby method use for invoking the object for example in layouts/apllication.html.erb we call yeild invoking the object page.
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?
False description | Nil description |
It is a boolean data type | nil in not a data type it have an object id 4 |
7) Mention what are the positive aspects of Rails?
Rails provides many features like
Rapid development: It provide the feature for fast deveopment. It does have huge community for support.
8) Explain what is the role of sub-directory app/controllers and app/helpers?
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?
Symbol is different from variables in following aspects
11) Explain what is Rails Active Record in Ruby on Rails?
Rails active record is the Object/Relational Mapping (ORM) layer supplied with Rails. It follows the standard ORM model as
12) Explain how Rails implements Ajax?
Ajax powered web page retrieves the web page from the server which is new or changed unlike other web-page where you have to refresh the page to get the latest information.
Rails triggers an Ajax Operation in following ways
13) Mention how you can create a controller for subject?
To create a controller for subject you can use the following command
14) Mention what is Rails Migration?
Rails Migration enables Ruby to make changes to the database schema, making it possible to use a version control system to leave things synchronized with the actual code.
15) List out what can Rails Migration do?
Rails Migration can do following things
16) Mention what is the command to create a migration?
To create migration command includes
C:\ruby\application>ruby script/generate migration table_name
17) Explain when self.up and self.down method is used?
When migrating to a new version, self.up method is used while self.down method is used to roll back my changes if needed.
18) Mention what is the role of Rails Controller?
The Rails controller is the logical center of the application. It faciliates the interaction between the users, views, and the model. It also performs other activities like
19) Mention what is the difference between Active support’s “HashWithIndifferent” and Ruby’s “Hash” ?
The Hash class in Ruby’s core library returns value by using a standard “= =” comparison on the keys. It means that the value stored for a symbol key cannot be retrieved using the equivalent string. While the HashWithIndifferentAccess treats Symbol keys and String keys as equivalent.
20) Explain what is Cross-Site Request Forgery (CSRF) and how Rails is protected against it?
CSRF is a form of attack where hacker submits a page request on your behalf to a different website, causing damage or revealing your sensitive data. To protect from CSRF attacks, you have to add “protect_from_forgery” to your ApplicationController. This will cause Rails to require a CSRF token to process the request. CSRF token is given as a hidden field in every form created using Rails form builders.
21) Explain what is Mixin in Rails?
Mixin in Ruby offers an alternative to multiple inheritances, using mixin modules can be imported inside other class.
22) Explain how you define Instance Variable, Global Variable and Class Variable in Ruby?
23) Explain how you can run Rails application without creating databases?
You can execute your application by uncommenting the line in environment.rb
path=> rootpath conf/environment.rb
config.frameworks = [ action_web_service, :action_mailer, :active_record]
24) Mention what is the difference between the Observers and Callbacks in Ruby on Rails?
25) Explain what is rake in Rails?
Rake is a Ruby Make; it is a Ruby utility that substitutes the Unix utility ‘make’, and uses a ‘Rakefile’ and ‘.rake files’ to build up a list of tasks. In Rails, Rake is used for normal administration tasks like migrating the database through scripts, loading a schema into the database, etc.
26) Explain how you can list all routes for an application?
To list out all routes for an application you can write rake routes in the terminal.
$ rail routes or rake routes
27) Explain what is sweeper in Rails?
Sweepers are responsible for expiring or terminating caches when model object changes.
28) Mention the log that has to be seen to report errors in Ruby Rails?
Rails will report errors from Apache in the log/Apache.log and errors from the Ruby code in log/development.log.
29) Explain what is the difference between Dynamic and Static Scaffolding?
Dynamic Scaffolding | Static Scaffolding |
|
|
30) Mention what is the function of garbage collection in Ruby on Rails?
The functions of garbage collection in Ruby on Rails includes
31) Mention what is the difference between redirect and render in Ruby on Rails?
32) Mention what is the purpose of RJs in Rails?
RJs is a template that produces JavaScript which is run in an eval block by the browser in response to an AJAX request. It is sometimes used to define the JavaScript, Prototype and helpers provided by Rails.
33) Explain what is Polymorphic Association in Ruby on Rails?
Polymorphic Association allows an ActiveRecord object to be connected with Multiple ActiveRecord objects. A perfect example of Polymorphic Association is a social site where users can comment on anywhere whether it is a videos, photos, link, status updates etc. It would be not feasible if you have to create an individual comment like photos_comments, videos_comment and so on.
34) Mention what are the limits of Ruby on Rails?
Ruby on Rails has been designed for creating a CRUD web application using MVC. This might make Rails not useful for other programmers. Some of the features that Rails does not support include
35) Mention what is the difference between calling super() and super call?
36) Explain about Dig, Float and Max?
37) Explain how can we define Ruby regular expressions?
Ruby regular expression is a special sequence of characters that helps you match or find other strings. A regular expression literal is a pattern between arbitrary delimiters or slashes followed by %r.
38) Explain what is the defined operator?
Define operator states whether a passed expression is defined or not. If the expression is defined, it returns the description string and if it is not defined it returns a null value.
39) List out the few features of Ruby?
40) Mention the types of variables available in Ruby Class?
Types of variables available in Ruby Class are,
41) Explain how can you declare a block in Ruby?
In Ruby, the code in the block is always enclosed within braces ({}). You can invoke a block by using “yield statement”.
42) Explain what is the difference between put and putc statement?
Unlike the puts statement, which outputs the entire string onto the screen. The Putc statement can be used to output one character at a time.
43) Explain what is a class library in Ruby?
Ruby class libraries consist of a variety of domains, such as thread programming, data types, various domains, etc. These classes give flexible capabilities at a high level of abstraction, giving you the ability to create powerful Ruby scripts useful in a variety of problem domains. The following domains which have relevant class libraries are,
44) In Ruby, it explains about the defined operator?
The defined operator tells whether a passed expression is defined or not. If the expression is not defined, it gives null, and if the expression is defined it returns the description string.
45) Mention what is the difference in scope for these two variables: @@name and @name?
The difference in scope for these two variables is that:
46) Mention what is the syntax for Ruby collect Iterator?
The syntax for Ruby collect Iterator collection = collection.collect.
47) In Ruby code, often it is observed that coder uses a short hand form of using an expression like array.map(&:method_name) instead of array.map { |element| element.method_name }. How this trick actually works?
When a parameter is passed with “&” in front of it. Ruby will call to_proc on it in an attempt to make it usable as a block. So, symbol to_Proc will invoke the method of the corresponding name on whatever is passed to it. Thus helping our shorthand trick to work.
48) Explain what is Interpolation in Ruby?
Ruby Interpolation is the process of inserting a string into a literal. By placing a Hash (#) within {} open and close brackets, one can interpolate a string into the literal.
49) Mention what is the Notation used for denoting class variables in Ruby?
In Ruby,
50) Mention what is the difference between Procs and Blocks?
The difference between Procs and Blocks,
51) Mention what is the difference between a single quote and double quote?
A single-quoted strings don’t process ASCII escape codes, and they don’t do string interpolation.
51) Mention what is the difference between a gem and a plugin in Ruby?
Thanks For reading
Team ShadBox Quiz and Blogging Platform
we have the “Get things executed” lifestyle at our place of work. There are not any excuses, no if’s or however’s in our dictionary. committed to navigating the ship of creativity to create cell answers, we resolve the real-lifestyles troubles of our clients and their clients. Our passion for work has won us many awards, year after 12 months.
© Copyright Shadbox. All Rights Reserved
Rate Blog :
Share on :
Do you have any blog suggestion? please click on the link