小编set*_*err的帖子

如何在Rails 3中用Draper装饰嵌套属性(关联)?

我的环境:

我正在使用嵌套资源,并且无法确定在何处声明装饰器.

#app/controllers/users_controller.rb
def show
  @user = UserDecorator.find(params[:id])
  @items = @user.items
end

#app/controllers/items_controller.rb
def show
  @item = @user.items.find(params[:id])
end
Run Code Online (Sandbox Code Playgroud)

我尝试更换items,ItemDecorator但没有用.我应该把它放在哪里?

我知道Draper在表单中存在嵌套资源的问题,但这不是表单!

ruby-on-rails nested-attributes draper

11
推荐指数
1
解决办法
4330
查看次数

标签 统计

draper ×1

nested-attributes ×1

ruby-on-rails ×1