Ruby on Rails Developer Question:

Please explain what is a Rails Migration? Write up a short example of a simple Rails Migration with a table called customers, a string column called name, and a text column called description.?

Answer:

Initiating the command c:rubyapplication>ruby script/generate migration table_name will create a Rails Migration. A Rails Migration can be used to create, drop, or remove tables and columns. A potential solution is provided below.

class CreateCustomers < ActiveRecord::Migration
def up
create_table :customers do |t|
t.string :name
t.text :description

t.timestamps
end
end

def down
drop_table :customers
end
end

Download Ruby on Rails Developer PDF Read All 30 Ruby on Rails Developer Questions
Previous QuestionNext Question
Tell me what is CoC in Rails?Tell us ruby Supports Single Inheritance/multiple Inheritance Or Both?