About presenter pattern in rails. is a better way to do it?
- by Totty
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