Blog (migration)

@fredwu 11 years ago | 2 min read | no comments
Update: You might also want to check out reset_column_information. So a few days ago we started seeing the following errors on our Jenkins builds (swapped with fictional model and attribute names): NoMethodError: undefined method `attack_power=' for #<Ironman:0x00000008525d20> attack_power is a new attribute we recently added to the Ironman ActiveRecord model. I was baffled, as the table column is clearly there but ActiveRecord couldn’t see it. This weird behaviour is confirmed by ...
@fredwu 14 years ago | 1 min read | no comments
Introduction ActiveRecord is without doubt the de facto ORM library for Rails and many Ruby web frameworks. Many developers however, do not like database migrations and prefer to use DSL for data mapping. Datamappify is created with the sole purpose of getting rid of the DB migration headaches. Why Not DB Migrations? Well, depending on your specific project, DB migrations might create more trouble than it’s worth. Besides, your code is already version controlled, so why create a separate versi...
@fredwu 14 years ago | 1 min read | no comments
So you were wondering why some of your model attributes weren’t updating properly? Well, it is perhaps because the db schema has changed but the changed schema has not been passed onto ActiveRecord, as is often the case in DB migration. Taken from the ActiveRecord documentation: Resets all the cached information about columns, which will cause them to be reloaded on the next request. The most common usage pattern for this method is probably in a migration, when just after creating a table you ...