draper

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

孤街醉人 提交于 2020-01-01 04:27:29
问题 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

How to include Draper Decorators in Rails Console?

为君一笑 提交于 2019-12-12 05:28:10
问题 I'd like to see the output of some of my Draper Decorators in Rails console (https://github.com/drapergem/draper and http://railscasts.com/episodes/286-draper). To do so, I was looking for a way to include a decorator and its methods similar to as we would an application helper: include ActionView::ApplicationHelper A draper decorator inherits from an ApplicationDecorator, which inherits from Draper::Base class ApplicationDecorator < Draper::Base end class MaterialDecorator <

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

冷暖自知 提交于 2019-12-03 11:37:06
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 many items