Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #excluding to ActiveRecord::Relation to exclude a record (or collection of records) from the resulting relation. #41439

Merged

Commits on Feb 16, 2021

  1. Implemented ActiveRecord::Relation#excluding method.

    This method excludes the specified record (or collection of records) from the resulting relation.
    
    For example: `Post.excluding(post)`, `Post.excluding(post_one, post_two)`, and `post.comments.excluding(comment)`.
    
    This is short-hand for `Post.where.not(id: post.id)` (for a single record) and `Post.where.not(id: [post_one.id, post_two.id])` (for a collection).
    GlenCrawford committed Feb 16, 2021
    Copy the full SHA
    690fdbb View commit details
    Browse the repository at this point in the history