Logo F2FInterview

Ruby Rails Interview Questions

Q   |   QA

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

Ruby Supports only Single Inheritance.

You can achieve Multiple Inheritance through MIXIN concept means you achieve using module by including it with classes. 

  • (-) 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

  • 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)

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

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: