Platinum Partner

Active Record To_hash

With this mix-in, you can have nice "to_hash" methods on your active record objects.  

I find it good for programming JSON apps.

In lib/ar_hashing.rb

module ActiveRecordHashing
  def to_hash
      Hash[*self.map{ |m| [m.id, m]}.flatten]               
  end
end


and in config/environment.rb

require 'ar_hashing'

class ActiveRecord::Associations::AssociationCollection
  include ActiveRecordHashing
end
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}