There are plenty of shortcuts with Ruby on Rail's implementation of migrations. Adding columns, removing column, add indexes, altering table or columns to just name a few. I recently ran across a simple trick that can be utilized to add multiple columns quickly to a migration
By utilizing the following formula with the Rails generator, you can add multiple columns to a single migration.
The Rails generate command is smart enough to figure out the correct database table and construct a migration based off it. I imagine this could also be used with other migrations, not just altering an existing table.
Got a Rails generate trick or tip? Tell me about it below in the comments.
« Previous Post
comments powered by Disqus
Recovering from common Ruby on Rails errors and pitfalls
Next Post »Create a many-to-many ActiveRecord association in Ruby on Rails with has_many :through and has_and_belongs_to_many
Join the conversation