Feed on
Posts
Comments

Category Archive for 'rails'

nested error_messages_for

I think lots of folks have run into this problem of using error_messages_for to display errors of nested or subordinate objects. The current Rails method doesn't handle it well. In addition, there's the problem of not being able to specify the full message. So... I tackled this problem today and came up [...]

Read Full Post »

Extending ActiveRecord with count_since

I just implemented a statistics page for an application and found that I was using this pattern over and over again:

User.count(:conditions => ['created_at> ?', 30.days.ago])

Here's a simple extension I made to ActiveRecord to DRY it up:

module ActiveRecord
  class Base
      def self.count_since(time_ago)
        count(:conditions => ['created_at> ?', time_ago])
      end
  end
end

Put [...]

Read Full Post »