draftsman icon indicating copy to clipboard operation
draftsman copied to clipboard

Performance: add options on `has_drafts` to whitelist or blacklist dependent associations

Open chrisdpeters opened this issue 8 years ago • 1 comments

Sometimes we may want to setup an aliased association with a scope, while including the original association as well.

I recently ran across the need to do something like this:

has_drafts

has_many :widgets
has_many :live_widgets, -> { live(:widgets) }, class_name: 'Widget'

The problem is that Draftsman will inspect both of those associations when querying for reversion and publication dependencies, which is unnecessary in many cases.

It makes sense to allow the option to only have Draftsman query one (or even neither) of those associations when identifying publication and reversion dependencies.

The API could possibly look like this:

has_drafts only_dependencies: [:widgets]

Or:

has_drafts without_dependencies: [:live_widgets]

chrisdpeters avatar Nov 05 '16 14:11 chrisdpeters

I think we should have an option to set custom dependencies, and it will disable automatic dependencies lookup if that option is set.

Something like:

# When publishing, publish child association instead of parrent association
has_drafts dependencies: [:child_association]

Looooong avatar Jan 23 '18 02:01 Looooong