Skip to content

Filtering Field::HasMany #1988

@vijuarez

Description

@vijuarez
  • What would you like to be able to do? Can you provide some examples?

See, I've got a lot of users with different characteristics on my app. For example, they all have a role, which is an enum. Some models have references to users, but some of them have restrictions related to roles. For example, you can't select an user who's a guess to be the editor on a post. I've got all of that figured out via validations, but it would be nice to have it reflected on the interface. As if, when I start editing the editors attribute on a certain post, only users with the role author or admin appear as options.

  • How could we go about implementing that?

Passing some kind of filter (maybe a function) to the field on user_dashboard.rb would be nice.

  • Can you think of other approaches to the problem?

I could just filter it out during rendering (modifying the partial for Field::HasMany), but that's not nice to do if I want to do it on a lot of dashboards with many different conditions. A minimal example on how to do this would be extremely useful to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions