Logo

The latest news in the Ruby and Rails community.

Subscribe to our mailing list!

Episode #413

October 22nd, 2013

This week: new Rails releases, upgrading to Rails 4 open-sourced, migrant attributes, a look at evolution of the distributed Travis architecture, and how GitHub models...

Stories

Migrant

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 even works with serialized attributes, it creates validations, and even allows for column type changes. You don’t have to, it infers foreign keys for associations based on association declarations in the models. It even creates indices for those foreign keys, and you can also declare indices manually.

Visit site → Permalink

Previous Episodes

Episode #412

RubinusX, details on a rewrite of ActiveModel::Serializers, using docker to parallelize your tests, cleaning up your use of Rails.env, and several other fun tidbits on this episode of Ruby5

Episode #411

Ruby refactorings, generate PDFs with Shrimp, speed up your Travis, infographic on the Ruby Stack and secure your Cookies.

Episode #410

Today only! Some feature testing tips, a tour through all things random with Ruby, Capistrano and Wicked get some updates, reactive_record, and your fairy godmother Ruby pays a visit to tell you all about Heroku support for Websockets.

Episode #409

One day, two rubies with Rubinius 2.0 and JRuby 1.7.5. MRI 2.1 vs Rubinius 2.0 benchmark, Virtus 1.0, Capistrano woes, and help Ruby on Sails.

View the archives →

Looking to learn about Ruby? Take a look at the Ruby Path on Code School

This podcast is produced and distributed by Code School. Copyright © 2015 Code School LLC