Ruby on Rails Developer Question: Download Questions PDF
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.?
![Ruby on Rails Developer Interview Answer Ruby on Rails Developer Interview Question](https://globalguideline.com/public/images/interview/32.png)
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
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 Interview Questions And Answers
PDF
Previous Question | Next Question |
Tell me what is CoC in Rails? | Tell us ruby Supports Single Inheritance/multiple Inheritance Or Both? |