Reputation: 2255
I have seen two different ways of migrating a database. Which one is the proper way to do it in Rails 3?
class CreateProducts < ActiveRecord::Migration
def self.up
create_table :products do |t|
t.string :title
t.timestamps
end
end
and
class CreateProducts < ActiveRecord::Migration
def self.up
create_table :products do |t|
t.column :name, :string
t.timestamps
end
end
Thank You!
Upvotes: 1
Views: 246
Reputation: 14973
t.string :title
is just a shortcut for t.column :title, :string
Both of them are ok, there is no discrimination. I'd normally prefer the short form, as it is more readable to me but it's just a matter of opinion.
Upvotes: 5