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.?
Submitted by: MuhammadInitiating 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
Submitted by: Muhammad
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
Submitted by: Muhammad
Read Online Ruby on Rails Developer Job Interview Questions And Answers
Top Ruby on Rails Developer Questions
☺ | What is RVM? |
☺ | What is Rails Scaffolding? |
☺ | Explain me what Are The Components Defined In The Model From Mvc Architecture? |
☺ | Please explain request/response cycle? |
☺ | Explain what’s different between ActiveRecord::Relation’s count, length and size methods? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |