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

issue with untagged (or not tagged) #1033

Open
francescor opened this issue May 2, 2021 · 1 comment
Open

issue with untagged (or not tagged) #1033

francescor opened this issue May 2, 2021 · 1 comment

Comments

@francescor
Copy link

I've defined this to get untagged entries

class TimeEntry < ApplicationRecord
...
  def self.untagged
    tagged_with(self.all_tag_names, exclude: true)
  end

which works fine if I want all untagged items: TimeEntry.untagged

It does not work (always return []) if I call it on a TimeEntry::ActiveRecord_Relation

TimeEntry.where(....).untagged

while it works if I get untagged items with

class TimeEntry < ApplicationRecord
...
  def self.untagged
    self.select { |time_entry| time_entry if time_entry.tag_list.empty? }
  end

Is it me, doing something I should not?

@c2ofh
Copy link

c2ofh commented Jun 3, 2021

Hi @francescor

I helped me out to find untagged entries by this statement (with your class-name):

scope :untagged, -> { left_outer_joins(:tags).where(tags: { id: nil }) }

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

No branches or pull requests

2 participants