Answers

Question and Answer:

  Home  Ruby on Rails Developer

⟩ 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.?

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

 202 views

More Questions for you: