mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00

## Description Include all QueryMethods from the ORM in CollectionDecorator. The default adapter is :active_record * Why was this change required? It was necessary to delegate or define a method of the ORM which you are using in your decorator to make an instance of CollectionDecorator able to call it. * Is there something you aren't happy with or that needs extra attention? In order to support other ORM associations, we'll need to write a method `allowed?` for each strategy at `lib/draper/query_methods/load_strategy.rb` ## Testing 1. Create a decorator for the model and its association ```ruby class OrderHistoryDecorator < Draper::Decorator delegate_all end class OrderDecorator < Draper::Decorator delegate_all decorates_association :order_histories, with: OrderHistoryDecorator end ``` 2. Call any query method in the decorated instance ```ruby pry(main)> Order.last.decorate.order_histories.includes(:user) ``` ## References * Issue #702 * Issue #812
15 lines
238 B
Ruby
15 lines
238 B
Ruby
source "https://rubygems.org"
|
|
|
|
gemspec
|
|
|
|
platforms :ruby do
|
|
gem 'sqlite3', '~> 1.3.6'
|
|
end
|
|
|
|
platforms :jruby do
|
|
gem "minitest"
|
|
gem "activerecord-jdbcsqlite3-adapter"
|
|
end
|
|
|
|
gem "rails", "~> 5.0"
|
|
gem "mongoid", github: "mongodb/mongoid"
|