I'm following the Draper gem documentation, but the associated model is not being decorated. Here's a snippet of my top-level decorator:
module Admin class OrderDecorator < Draper::Decorator delegate_all decorates_finders decorates_association :line_item def amount model.amount.nil? ? 0 : model.amount end end end
And here's a snippet from my association decorator:
module Admin class LineItemDecorator < Draper::Decorator delegate_all def options model.options.present? ? model.options.to_s : 'N/A' end end end
Here's the method in the controller that calls the decorator:
def show @subject = Admin::OrderDecorator.find(params[:id]) end
It's being used in the view like so:
@subject.line_items.each do |li| = li.options
The options method on LineItemDecorator is just being ignored - if it's nil, it doesn't display anything, rather than 'N/A'. I've put binding.pry in the options method and it never gets called. Can anyone see what I'm missing?
Thanks so much in advance.