Skip to content
cavalle edited this page Dec 23, 2012 · 13 revisions

a.k.a. Decorators / View objects / View models

Version #1

http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decompose-fat-activerecord-models/

class DonutChart
  def initialize(snapshot)
    @snapshot = snapshot
  end

  def cache_key
    @snapshot.id.to_s
  end

  def data
    # pull data from @snapshot and turn it into a JSON structure
  end
end

Clone this wiki locally