24 Oct '13, 9am

Ruby5 に週末話してた migrant の話でてた #railstokyo

While playing with a brand new Rails 4 app this weekend I discovered a gem I wish I had known about years ago, it’s called migrant and it provides a simple DSL to define attributes inside your model so it’s easy to reference them. Unlike other gems like annotate_models or annotator, migrant offers a neat auto­ migration feature. I think Rails migration generators are a neat feature when discovering it, it’s always weird to me to be deciding what fields my ActiveRecord models should have in the console, instead of inside the model itself. With migrant, you call a structure method inside of your model, pass it a block. Within this block you can define the names of your model’s columns. You can specify their type, and even give example data or add comments to them. You just call rake db:upgrade and it will create a migration for each model and their respective attributes. It ...

Full article: http://ruby5.envylabs.com/episodes/449-episode-413-octobe...

Tweets