views:

13

answers:

0

For example:

class Tree
  has_many :apples
end

class Apple
  belongs_to :tree
end

class ApplePresenter
  presents :apple

  def name
    @apple.name.upcase
  end
end 

class TreePresenter
  presents :tree

  def apples
    present_collection @tree.apples
  end
end

Using this, there's no need to duplicate the ApplePresenter methods and do some more elaborate iteration on the Tree.apples association.

To take this one step further: Does the fact that TreePresenter has no methods other than apples change the answer? It's basically a wrapper around the other (Apple) presenter to use in a view that's basically a parent (ie Tree) view.

I'm using http://github.com/zdennis/caching_presenter.