Blogger.create { :name =>'Matt Aimonetti',
:location => 'San Diego, Ca',
:email => mattaimonetti AT gmail.com,
:linkedin => Matt's Linkedin page,
:recommend_me => HERE,
:contractor => true}

Rails, sexier than ever.

Written by matt on March 30th, 2007

3 days ago, Edge was patched to add a nicer syntax to our dear migrations.

Instead of doing:
create_table :people do |t| t.column :name, :string t.column :age, :integer end You can now do: create_table :people do |t| t.name :string t.age :integer end

While this is great, I found out that someone came up with an even nicer way of creating your migration, actually, a sexier way of doing migrations, and we all like sexy, don’t we? Otherwise we would not use Rails, would we?

Anyway thanks to this new plugin, your old Migration:

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

can look sexier than ever: 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

Note that I didn’t test the code above and the self.up method seems to be missing, for more information, check the official post to give it a try: ./script/plugin install svn://errtheblog.com/svn/plugins/sexy_migrations



Comments are closed