Skip to content

Add regular expression tag searches #11

Open
@esb

Description

@esb

As a quick exercise, I have added the ability to search the array values with a regular expression.

The following scope was added to taggable.rb

scope :"with_#{tag_name}_like", ->(pattern) { subquery = unscoped.select("*, unnest(#{table_name}.#{tag_name}) AS subquery_tag"); select('*').from(subquery).where('subquery_tag ~* ?', pattern) }

This allows you to get tags as follows:

Object.with_tags_like('^Material')
Object.with_tags_like('^(Wood|Iron)')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions