Home
6.
What is ORM in Rails?

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

7.
How many Types of Associations Relationships does a Model has?

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:

  1. 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.
  2. 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.
  3. 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.

8.
What is the Difference between Static and Dynamic Scaffolding?

The Syntax of Static Scaffold is like this:
ruby script/generate scaffold User Comment.
Where Comment is the model and User is your controller, So all n all static scaffold takes 2 parameter i.e your controller name and model name, whereas in dynamic scaffolding you have to define controller and model one by one.

9.
How you run your Rails Application without creating database ?

MYou can run application by uncomment the line in environment.rb
Path => rootpath conf/ environment.rb
# Skip frameworks you're not going to use (only works if using vendor/rails)
config.frameworks -= [ :action_web_service, :action_mailer,:active_record ].

10.
What are helpers and how to use helpers in ROR?

Helpers ("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. It's best if the view file (RHTML/RXML) is short and sweet, so you can see the structure of the output.