How to decorate nested attributes (associations) with Draper in Rails 3? -
my environment:
- rails 3.2
- with draper gem
i'm using nested resources , having trouble figuring out declare 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 itemdecorator , didn't work. should putting it?
i know draper has issues nested resources in forms, isn't form!
as far i've understood problem correctly, you've model user has many items, items not decorated?
so add userdecorator:
class userdecorator < draper::base decorates :user decorates_association :items #, :with => :item [..] end class itemdecorator < draper::base decorates :item [..] end have on the source.
Comments
Post a Comment