Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A administrate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 32
    • Merge requests 32
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • thoughtbot, inc.
  • administrate
  • Merge requests
  • !333

Configure the scope on has many fields

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/zamith/configure-has-many-scope into master Dec 14, 2015
  • Overview 18
  • Commits 5
  • Pipelines 0
  • Changes 5

Created by: zamith

Why:

  • Many times we want to select from a list of resources that is scope. For instance, a user might be scoped by role.

This change addresses the need by:

  • Allowing an option to be passed to the HasMany field, with a proc to be run

Usage:

ATTRIBUTE_TYPES = {
  admins: Field::HasMany.with_options(class_name: "User", scope: -> { User.admins }),
}

Fixes #331 (closed)

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/zamith/configure-has-many-scope