3 ms·
The biggest pain points that gems like Draper solve are allowing view helpers in your decorators (which is by no means straightforward when you get into routing
by ryanbrunner 13y ago
The biggest pain points that gems like Draper solve are allowing view helpers in your decorators (which is by no means straightforward when you get into routing helpers), and dealing with some of the strangeness that you get into by wrapping ActiveRecord models (JSON serialization was a biggie for us). It's less about what Ruby gives you, and more about navigating around some of the darker, messier corners of Rails.
- rubiquity 13y agoThey just wrapped the view_context with a method_missing proxy (another form of a Decorator) that the controller instance gives you. You can accomplish the same very easily using dependency injection in your controller action: MassivelyUpVotedPostPresenter.new(@post, self.view_context) Or just inject the whole controller instance and you have your router helpers too! MassivelyUpVotedPostPresenter.new(@post, self)