Giving You More Free Time

Posted by shane
on Tuesday, May 29

(and previously Hobo and the Sexy Migrations plugin) gave us automatic created\_at and updated\_at fields in our migrations, using the timestamps keyword.

How about bringing some of this sexiness to generators and taking it a step further? Well my patch was accepted and Rails now automatically adds timestamps to all generated migrations. So when you generate a model, scaffold, or resource, you will get timestamps for free. It is the equivalent of adding created\_at:datetime and updated\_at:datetime to your generators. So

script/generate model post title:string
will do the same thing as
script/generate model post title:string created\_at:datetime updated\_at:datetime

This is nothing significant but I hope it saves people a few keystrokes. If you don’t need timestamps you can always just delete the associated lines from your migration file and the fixtures. Just another example of Rails making it easier to do common things. This is currently only available in Edge Rails.

Comments

Leave a response

  1. TimJuly 05, 2007 @ 08:18 AM
    There are a lot of really interesting and handy stuffs in Rails. They make my comp life much better and as you've said much more free time ;)
  2. TimJuly 05, 2007 @ 08:21 AM
    There are a lot of really interesting and handy stuffs in Rails. They make my comp life much better and as you've said much more free time ;)
Comment