Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

51.

What Is Mvc? And How It Works?

Answer»

MVC tends for MODEL-View-Controller, used by many languages like PHP, Perl, PYTHON etc. The flow goes like this:

REQUEST first comes to the controller, controller finds and appropriate view and interacts with model, model interacts with your database and send the response to controller then controller BASED on the response give the output parameter to view.

MVC tends for Model-View-Controller, used by many languages like PHP, Perl, Python etc. The flow goes like this:

Request first comes to the controller, controller finds and appropriate view and interacts with model, model interacts with your database and send the response to controller then controller based on the response give the output parameter to view.

52.

What Are Helpers And How To Use Helpers In Ror?

Answer»

Helpers are modules that provide methods which are automatically usable in your VIEW. They provide SHORTCUTS to COMMONLY used display code and a WAY for you to keep the programming out of your views. The PURPOSE of a helper is to simplify the view.

Helpers are modules that provide methods which are automatically usable in your view. They provide shortcuts to commonly used display code and a way for you to keep the programming out of your views. The purpose of a helper is to simplify the view.

53.

How Many Types Of Associations Relationships Does A Model Have?

Answer»

When you have more than one model in your rails application, you would need to create connection between those models. You can do this via associations. Active Record supports three TYPES of associations:

one-to-one: A one-to-one RELATIONSHIP EXISTS when one item has exactly one of another item. For example, a person has exactly one BIRTHDAY or a dog has exactly one owner.

one-to-many: A one-to-many relationship exists when a single object can be a member of many other objects. For instance, one subject can have many books.

many-to-many: A many-to-many relationship exists when the first object is related to one or more of a SECOND object, and the second object is related to one or many of the first object.

You indicate these associations by adding declarations to your models: has_one, has_many, belongs_to, and has_and_belongs_to_many.

When you have more than one model in your rails application, you would need to create connection between those models. You can do this via associations. Active Record supports three types of associations:

one-to-one: A one-to-one relationship exists when one item has exactly one of another item. For example, a person has exactly one birthday or a dog has exactly one owner.

one-to-many: A one-to-many relationship exists when a single object can be a member of many other objects. For instance, one subject can have many books.

many-to-many: A many-to-many relationship exists when the first object is related to one or more of a second object, and the second object is related to one or many of the first object.

You indicate these associations by adding declarations to your models: has_one, has_many, belongs_to, and has_and_belongs_to_many.

54.

What Is Orm In Rails?

Answer»

ORM tends for Object-Relationship-Model, where Classes are MAPPED to table in the DATABASE, and OBJECTS are DIRECTLY mapped to the rows in the table.

ORM tends for Object-Relationship-Model, where Classes are mapped to table in the database, and Objects are directly mapped to the rows in the table.

55.

What Do You Mean By Render And Redirect_to?

Answer»

render causes rails to generate a RESPONSE WHOSE CONTENT is provided by rendering one of your templates. Means, it will direct goes to view page.

redirect_to generates a response that, instead of DELIVERING content to the browser, just tells it to request ANOTHER url. Means it first checks actions in controller and then goes to view page.

render causes rails to generate a response whose content is provided by rendering one of your templates. Means, it will direct goes to view page.

redirect_to generates a response that, instead of delivering content to the browser, just tells it to request another url. Means it first checks actions in controller and then goes to view page.

56.

Why Ruby On Rails?

Answer»

There are lot of advantages of using ruby on rails.

  1. DRY Principal( Don’t Repeat Yourself): It is a principle of software development aimed at reducing repetition of code. “Every piece of code must have a single, unambiguous representation within a system”
  2. Convention over Configuration: Most web development framework for .NET or Java force you to write pages of configuration code. If you follow suggested naming conventions, Rails doesn’t need much configuration.
  3. Gems and Plugins: RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing ruby programs and library.
  4. Plugins: A Rails plugin is either an extension or a modification of the core framework. It provides a way for developers to share bleeding-edge ideas without hurting the stable code base. We need to decide if our plugin will be potentially shared across different Rails applications.

  5. Scaffolding: Scaffolding is a meta-programming method of building database-backend software application. It is a technique supported by MVC frameworks, in which programmer may write a specification, that describes how the application database may be used. There are two type of scaffolding:
  6. -STATIC: Static scaffolding takes 2 parameter i.e your controller NAME and model name.

    -dynamic: In dynamic scaffolding you have to define controller and model ONE by one.

  7. Rack Support: Rake is a software task management tool. It allows you to specify tasks and describe dependencies as well as to group tasks in a namespace.
  8. METAPROGRAMMING: Metaprogramming techniques use programs to write programs.
  9. BUNDLER: Bundler is a new concept introduced in Rails 3, which helps you to manage your gems for application. After specifying gem file, you need to do a bundle install.
  10. Rest Support.
  11. Action Mailer

There are lot of advantages of using ruby on rails.

Plugins: A Rails plugin is either an extension or a modification of the core framework. It provides a way for developers to share bleeding-edge ideas without hurting the stable code base. We need to decide if our plugin will be potentially shared across different Rails applications.

-static: Static scaffolding takes 2 parameter i.e your controller name and model name.

-dynamic: In dynamic scaffolding you have to define controller and model one by one.

57.

Explain About Restful Architecture?

Answer»

RESTful: REST STANDS for Representational State Transfer. REST is an architecture for designing both web applications and application programming interfaces (API’s), that’s uses HTTP.

RESTful interface means clean URLs, less CODE, CRUD interface. CRUD means Create-READ-UPDATE-DESTROY. In REST, they add 2 NEW verbs, i.e, PUT, DELETE.

RESTful: REST stands for Representational State Transfer. REST is an architecture for designing both web applications and application programming interfaces (API’s), that’s uses HTTP.

RESTful interface means clean URLs, less code, CRUD interface. CRUD means Create-READ-UPDATE-DESTROY. In REST, they add 2 new verbs, i.e, PUT, DELETE.

58.

What Are The Various Components Of Rail?

Answer»
  1. Action Pack: Action Pack is a single gem that contains Action Controller, Action View and Action Dispatch. The “VC” part of “MVC”.
  2. Action Controller: Action Controller is the component that manages the controllers in a Rails application. The Action Controller framework processes incoming requests to a Rails application, extracts parameters, and DISPATCHES them to the intended action.

    Services provided by Action Controller include session management, template rendering, and redirect management.

    Action View: Action View manages the views of your Rails application. It can create both HTML and XML output by default.

    Action View manages rendering templates, including nested and partial templates, and includes built-in AJAX support.

    Action Dispatch: Action Dispatch handles routing of web requests and dispatches them as you want, either to your application or any other Rack application. Rack applications are a more advanced topic and are covered in a separate guide called Rails on Rack.

  3. Action Mailer: Action Mailer is a framework for building e-mail services. You can use Action Mailer to receive and process incoming email and send simple plain text or complex multipart EMAILS based on flexible templates.
  4. Active Model: Active Model provides a defined interface between the Action Pack gem services and Object Relationship Mapping GEMS such as Active Record. Active Model allows Rails to utilize other ORM frameworks in place of Active Record if your application needs this.
  5. Active Record: Active Record are LIKE Object Relational Mapping (ORM), where classes are mapped to table, objects are mapped to columns and object attributes are mapped to data in the table.
  6. Active Resource: Active Resource provides a framework for managing the connection between business objects and RESTful web services. It implements a way to map web-based resources to local objects with CRUD semantics.
  7. Active Support: Active Support is an extensive collection of utility classes and standard Ruby library extensions that are used in Rails, both by the core code and by your applications.

Action Controller: Action Controller is the component that manages the controllers in a Rails application. The Action Controller framework processes incoming requests to a Rails application, extracts parameters, and dispatches them to the intended action.

Services provided by Action Controller include session management, template rendering, and redirect management.

Action View: Action View manages the views of your Rails application. It can create both HTML and XML output by default.

Action View manages rendering templates, including nested and partial templates, and includes built-in AJAX support.

Action Dispatch: Action Dispatch handles routing of web requests and dispatches them as you want, either to your application or any other Rack application. Rack applications are a more advanced topic and are covered in a separate guide called Rails on Rack.