Sexy Migrations
ウェブ見回ってたら、面白いプラグインを見つけた。
コレまでdb/migrateにこう書いていたのが
class UpdateYourFamily < ActiveRecord::Migration create_table :updates do |t| t.column :user_id, :integer t.column :group_id, :integer t.column :body, :text t.column :type, :string t.column :created_at, :datetime t.column :updated_at, :datetime end def self.down drop_table :updates end end
こう書ける
class UpdateYourFamily < ActiveRecord::Migration create_table :updates do foreign_key :user foreign_key :group text :body string :type timestamps! end def self.down drop_table :updates end end