Clever ways of dealing with machine tags

Hey all

I’m using acts_as_taggable_on_steroids. I’m about to add some methods
for dealing with machine tags, and wondered if there was already some
received wisdom (or even code) for doing this sort of thing.

For example, the taggable model is called ‘question’. It can have a
curriculum subject and a curriculum ‘strand’, and also a theme, which is
outside the context of the curriculum. I was planning on having machine
tags like so:

curriculum:subject=Music
curriculum:strand=Instruments
theme:name=Christmas

Now, a question can have a lot of themes but it can only have one
curriculum subject and one curriculum strand at a time.

So, i could have methods like this, for example, which is not very
clever:

def subject=(s)
#clear current subject tags, if any
current_subject_tags = self.tags.select{|tag| tag.name =~
/^curriculum:subject=/}
unless current_subject_tags.blank?
current_subject_tags.each do |tag|
self.tag_delete(tag.name)
end
end
#now apply the new tag
self.tag_with(“curriculum:subject=#{s}”)
end

But, like i say, this seems kind of clumsy. Is there some existing
wisdom for this sort of thing?

Have you looked into acts-as-taggable-on?

Hi Nat - yes i have. We’re already using machine tags to denote context
in other situations, and i need to stick to the machine tag format. So
aato’s not appropriate in this instance as it uses its own mechanism for
denoting tag context.

thanks though
max