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
Recent
Articles
feed- Googlecharts featured on Github (June 27th)
- About Metaprogramming speed (June 18th)
- News update (June 17th)
- Avoid using metaprogramming (seriously!) (May 4th)
- BarCamp San Diego rev.3 (April 27th)
- Freezing Rails with Git (April 16th)
- Merb tip - how to freeze a project? (April 15th)
- Rails or Merb, what's best for you? (April 10th)
- Merb tips II (April 7th)
- Merb tips I (April 4th)
- How Duplo (and I) offended people (March 20th)
- Ruby on Rails: the Duplo generation (March 16th)
- starting the migration to GitHub (March 4th)
- How to use github and submit a patch (March 3rd)
- resolving git-svn conflicts (February 29th)
Comments
feed- Scott onAjax Pagination in less than 5 minutes
- Emmanuel Oga onAbout Metaprogramming speed
- Emmanuel Oga onAbout Metaprogramming speed
- Matt Aimonetti onNews update
- Bradly Feeley onNews update
- Roberto onAjax Pagination in less than 5 minutes
- R. Elliott Mason onRails or Merb, what's best for you?
- Alain onSexy charts in less than 5 minutes
- Rob Kaufman onAvoid using metaprogramming (seriously!)
- Tim Harper onAvoid using metaprogramming (seriously!)
- Tim Harper onAvoid using metaprogramming (seriously!)
- Ken Miller onAvoid using metaprogramming (seriously!)
- Ken Miller onAvoid using metaprogramming (seriously!)
- DaveS onAvoid using metaprogramming (seriously!)
- allen onAvoid using metaprogramming (seriously!)
Archives
Archives
- June 2008 (3)
- May 2008 (1)
- April 2008 (6)
- March 2008 (4)
- February 2008 (2)
- January 2008 (2)
- December 2007 (8)
- November 2007 (5)
- October 2007 (5)
- September 2007 (6)
- August 2007 (5)
- July 2007 (11)
- June 2007 (10)
- May 2007 (7)
- April 2007 (4)
- March 2007 (3)


