About presenter pattern in rails. is a better way to do it?

Posted by Totty on Stack Overflow See other posts from Stack Overflow or by Totty
Published on 2010-05-12T19:55:23Z Indexed on 2010/05/12 20:04 UTC
Read the original article Hit count: 121

I have in my model:

def presenter
   @presenter ||= ProfilePresenter.new(self)
   @presenter
end

The ProfilePresenter is a class that has methods like, get_link(), get_img_url(size), get_sex(), get_relationship_status() and other methods that have not to do with the model, not even with the controller but is used multiple times in the view.

So now i use them by doing this:

Profile.presenter.get_link
# or
Profile.presenter.get_img_url('thumb') # returns the path of the image. is not used to make a db query

© Stack Overflow or respective owner

Related posts about model-view-presenter

Related posts about ruby-on-rails