My models look like this:
class Ticket < ActiveRecord::Base has_and_belongs_to_many :tags end class Tag < ActiveRecord::Base has_and_belongs_to_many :tickets end
I want to have an area that gives me all the different Tickets
that are not marked unresolved
(as in tag.name != "unresolved"
)
How can I do it? For example, if 1 ticket has 6 tags (one of which is unresolved
), I want to return only one copy of this ticket, and not 5 in the field. I managed to do the opposite (all Tickets
marked with unresolved
tags) as such:
scope :unresolved, :select => "DISTINCT tickets.*", :joins => :tags, :conditions => "tags.name = 'unresolved'"
source share