Tag Archives: rails 2.1

Rails 2.1: UTC-Timestamped Migrations

Rails 2.1 introduces UTC-timestamped migrations–instead of a single, three-digit prefix to your number, you now get a timestamp (everything from the current year to the current second). This helps you resolve conflicts of the same-numbered migration showing up in multi-developer environments; but it’s annoying sometimes! How can you turn this off? Through environment.rb! Continue reading

Posted in Development, Projects | Tagged , , | Comments Off

Rails 2.1: Increment and Decrement Value

Prior to Rails 2.1, the increment and decrement functions needed to be called multiple times if you wanted to increment/decrement by more than one. In Rails 2.1, you can pass in a second parameter: a value, how much to increment or decrement the field by. (And it can take negative values.) Continue reading

Posted in Development | Tagged , | Comments Off

Rails 2.1: Aggregate Expressions

Rails 2.1 allows you to perform complex aggregate queries, such as Donation.sum(“amount * 3″). This makes complex calculations a snap! Rails provides functions for calculating the average, count, maximum, minimum, and the sum. Continue reading

Posted in Development | Tagged , , | Comments Off

Rails 2.1: Named Scope

Rails 2.1 introduces something called named scopes; named scopes allow you to create named collections on a class-level for your models, such as Article.published. You can chain named scopes together, and even create parameterizable scopes by using the lambda keyword; you can pass in variables, of a sort, and Rails will plug the values into your named scope queries. Continue reading

Posted in Development | Tagged , , | 4 Comments

Rails 2.1: The First and the Last

Rails always made it easy to grab the first item in any ActiveRecord model. Rails 2.1 allows you to easily grab the last element, too, with the syntax ActiveRecord.find(:last). Like :first, you can add limits, conditions, etc. to it. Additionally, there are new static methods to allow you to call ActiveRecord.first and ActiveRecord.last to get the first and last elements respectively. Yay! Continue reading

Posted in Development | Tagged , , | Comments Off

Rails 2.1 eBook

When Rails 2.1 was released, Carlos Brando released an e-book documenting all of the new features. You can snag the PDF here. It covers: timezone support, dirty tracking, gem dependencies, named scope, UTC-based migrations, and better caching, in addition to a whole slew of smaller updates. Continue reading

Posted in Development, News | Tagged , , | 1 Comment