Q1 : What is “Yield” in Ruby on Rails?
A : A Ruby method that receives a code block invokes it by calling it with the “Yield”.
Q2 : What is Rails Active Record in Ruby on Rails?
A : Rails active record is the Object/Relational Mapping (ORM) layer supplied with Rails. It follows the standard ORM model as
- Table map to classes
- Rows map to objects
- Columns map to object attributes
Q3 : What is Rails Migration?
A : 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.
Q4 : List out what can Rails Migration do?
A : Rails Migration can do following things
- Create table
- Drop table
- Rename table
- Add column
- Rename column
- Change column
- Remove column and so on
Q5 : What is rake in Rails?
A : 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.
Q6 : What is sweeper in Rails?
A : Sweepers are responsible for expiring or terminating caches when model object changes.
Q7 : What is the function of garbage collection in Ruby on Rails?
A : The functions of garbage collection in Ruby on Rails includes
- It enables the removal of the pointer values which is left behind when the execution of the program ends
- It frees the programmer from tracking the object that is being created dynamically on runtime
- It gives the advantage of removing the inaccessible objects from the memory and allows other processes to use the memory
Q8 : What is the purpose of RJs in Rails?
A : 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.
Q9 : What are the limits of Ruby on Rails?
A : 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
- Foreign key in databases
- Linking to multiple data-base at once
- Soap web services
- Connection to multiple data-base servers at once
Q10 : List out the few features of Ruby?
A :
- Free format – You can start writing from program from any line and column
- Case sensitive – The uppercase and lowercase letters are distinct
- Comments – Anything followed by an unquoted #, to the end of the line on which it appears, is ignored by the interpreter
- Statement delimiters- Multiple statements on one line must be separated by semicolons, but they are not required at the end of a line.
Q11 : In Ruby, it explains about the defined operator?
A : 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.
Q12 : What is Interpolation in Ruby?
A : 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.
Q13 : What is the difference between a gem and a plugin in Ruby?
A :
- Gem: A gem is a just ruby code. It is installed on a machine, and it’s available for all Ruby applications running on that machine.
- Plugin: Plugin is also ruby code, but it is installed in the application folder and only available for that specific application.
Q14 : What is the syntax for Ruby collect Iterator?
A : The syntax for Ruby collect Iterator collection = collection.collect.
Q15 : What is the difference extend and include?
A : The “include” makes the module’s methods available to the instance of a class, while “extend” makes these methods available to the class itself.
Q16 : What is a class library in Ruby?
A : 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,
- GUI programming
- Network programming
- CGI Programming
- Text processing
Q17 : List out the few features of Ruby?
A :
- Free format – You can start writing from program from any line and column
- Case sensitive – The uppercase and lowercase letters are distinct
- Comments – Anything followed by an unquoted #, to the end of the line on which it appears, is ignored by the interpreter
- Statement delimiters- Multiple statements on one line must be separated by semicolons, but they are not required at the end of a line.
Q18 : Explain about Dig, Float, and Max?
A :
- Float class is used whenever the function changes constantly.
- Dig is used whenever you want to represent a float in decimal digits.
- Max is used whenever there is a huge need of Float.
Q19 : What is Polymorphic Association in Ruby on Rails?
A : 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 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.
Q20 : Mention the log that has to be seen to report errors in Ruby Rails?
A : Rails will report errors from Apache in the log/Apache.log and errors from the Ruby code in log/development.log.
Q21 : What is Mixin in Rails?
A : Mixin in Ruby offers an alternative to multiple inheritances, using mixin modules can be imported inside other class.
Q22 : What is the command to create a migration?
A : To create migration command includes
C:\ruby\application>ruby script/generate migration table_name
Q23 : What is Cross-Site Request Forgery (CSRF) and how Rails is protected against it?
A : 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.
Q24 : How you can create a controller for subject?
A : To create a controller for subject you can use the following command
C:\ruby\library> ruby script/generate controller subject
Q25 : How Rails implements Ajax?
A : Ajax-powered web page retrieves the web page from the server which is new or changed unlike another web-page where you have to refresh the page to get the latest information.
Rails trigger an Ajax Operation in the following ways
- Some trigger fires: The trigger could be a user clicking on a link or button, the users inducing changes to the data in the field or on a form
- Web client calls the server: A Java-script method, XMLHttpRequest, sends data linked with the trigger to an action handler on the server. The data might be the ID of a checkbox, the whole form or the text in the entry field
- Server does process: The server-side action handler does something with the data and retrieves an HTML fragment to the web client
- Client receives the response: The client-side JavaScript, which Rails generate automatically, receives the HTML fragment and uses it to update a particular part of the current
Comments are closed.