How to decorate nested attributes (associations) with Draper in Rails 3?

冷暖自知 提交于 2019-12-03 11:37:06

As far as I've understood your problem correctly, you've a model user which has many items, but your items were not decorated?

So add to your UserDecorator:

class UserDecorator < Draper::Base
  decorates :user
  decorates_association :items #, :with => :item 

  [..]
end

class ItemDecorator < Draper::Base
  decorates :item

  [..]
end

Have a look on the source.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!