- Home
- Interview Questions
- Ruby and Rails
11.
What is 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
12.
Ruby Support Single Inheritance/Multiple Inheritance or Both?
SRuby Supports only Single Inheritance.
You can achieve Multiple Inheritance through MIXIN concept means you achieve using module by including it with classes.
13.
How many types of callbacks available in ROR?
- (-) save
- (-) valid
- (1) before_validation
- (2) before_validation_on_create
- (-) validate
- (-) validate_on_create
- (3) after_validation
- (4) after_validation_on_create
- (5) before_save
- (6) before_create
- (-) create
- (7) after_create
- (8) after_save
14.
What can Rails migration do?
- create_table(name,options)
- drop_table(name)
- rename_table(old_name, new_name)
- add_column(table_name,column_name, type, options)
- rename_column(table_name,column_name, new_column_name)
- change_column(table_name, column_name, type, options)
- remove_column(table_name,column_name)
- add_index(table_name,column_name, index_type)
- remove_index(table_name,column_name)
Migrations support all the basic data types: string, text, integer, float, datetime, timestamp, time, date, binary and boolean:
- string - is for small data types such as a title.
- text - is for longer pieces of textual data, such as the description.
- integer- is for whole numbers.
- float- is for decimals.
- datetime and timestamp - store the date and time into a column.
- date and time - store either the date only or time only.
- binary - is for storing data such as images, audio, or movies.
- boolean - is for storing true or false values.
Valid column options are:
- limit ( :limit => “50” )
- default (:default => “blah” )
- null (:null => false implies NOT NULL)
15.
What is the naming conventions for methods that return a boolean result?
Methods that return a boolean result are typically named with a ending question mark. For example: def active? return true #just always returning true end.