{"issue":{"state":"closed","pull_request":{"diff_url":null,"html_url":null,"patch_url":null},"user":{"avatar_url":"https://secure.gravatar.com/avatar/e009bcdb7514d36b38361369bd10ba42?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"e009bcdb7514d36b38361369bd10ba42","url":"https://api.github.com/users/aka47","login":"aka47","id":7011},"milestone":null,"assignee":null,"labels":[],"updated_at":"2011-10-29T10:33:10Z","closed_at":"2011-10-29T10:33:04Z","comments":1,"url":"https://api.github.com/repos/jcasimir/draper/issues/66","body":"we have a complex domain logic and of course too complicated views. So drapper looks quite nice. But our pages are most of the time mixed resources, a user - has-many x which belongs to y.\r\n\r\nIn the view we are using helpers from all this objects.\r\n\r\nA simple and powerful solution is to auto-decorate any Model via method-missing if we are in a view... \r\n\r\n```ruby\r\nclass MyModel  < ActiveRecord::Base\r\n\r\n  ...\r\n\r\n  def decorator\r\n    @decorator ||= MyModelDecorator.new(self)\r\n  end\r\n\r\n  def method_missing(method_name, *args, &block)\r\n    Rails.logger.error(\"method_name #{method_name}\")\r\n    #Rails.logger.error(Draper::ViewContext.current)\r\n    super(method_name, *args, &block) unless Thread.current[:current_view_context] \r\n\r\n    begin\r\n      decorator.send(method_name, *args, &block) \r\n    rescue NoMethodError\r\n      super\r\n    end\r\n  end\r\nend\r\n```\r\n\r\nbut i am not sure if this i too powerful and it also could create way too many objects under the hood. \r\nWhat do you think?","html_url":"https://github.com/jcasimir/draper/issues/66","number":66,"title":"auto-decorate?","id":2059421,"created_at":"2011-10-26T17:53:19Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/e009bcdb7514d36b38361369bd10ba42?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"e009bcdb7514d36b38361369bd10ba42","url":"https://api.github.com/users/aka47","login":"aka47","id":7011},"updated_at":"2011-10-29T10:33:10Z","url":"https://api.github.com/repos/jcasimir/draper/issues/comments/2564350","body":"i guess we found a better, explizit way... ","id":2564350,"created_at":"2011-10-29T10:33:10Z"}}