Skip to content

Conversation

@andrjuha01
Copy link

@andrjuha01 andrjuha01 commented Oct 4, 2020

Right now gem can interact with attributes and relations only via :if block. It seems to be a really easy change to support :unless conditional as Rails does in validate method.
Inspired by this Issue.

Can be merged after this pr.
Would like to hear any feedback.

What is the current behavior?

has_many :actors, if: Proc.new { |record| record.actors.any? }

What is the new behavior?

has_many :actors, unless: Proc.new { |record| record.actors.empty? }

Checklist

Please make sure the following requirements are complete:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes /
    features)
  • All automated checks pass (CI/CD)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant