My environment:
- Rails 3.2
- with draper gem
I'm using nested resources and having trouble figuring out where to declare the decorator.
#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
I tried replacing items
with ItemDecorator
and it didn't work. Where should I be putting it?
I know that Draper has issues with nested resources in forms, but this isn't a form!
As far as I've understood your problem correctly, you've a model
user
which has manyitems
, but youritems
were not decorated?So add to your
UserDecorator
:Have a look on the source.