Chapter 11. Tagging
This chapter covers
- Tagging specific records for easier searching
- Restricting user access to tagging functionality
- Searching for specific tags or specific states of a ticket
In chapter 10, you saw how to give your tickets states (New, Open, and Closed) so that their progress can be indicated.
In this chapter, you’ll see how to give your tickets tags. Tags are useful for grouping similar tickets together into things such as iterations[1] or similar feature sets. If you didn’t have tags, you could crudely group tickets together by setting a ticket’s title to something such as “Tag - [name].” This method, however, is messy and difficult to sort through. Having a group of tickets with the same tag will make them much, much easier to find.
1 For example, by using a process such as Agile, feature sets, or any other method of grouping.
To manage tags, you’ll set up a Tag model, which will have a has_and_belongs_to_many association to the Ticket model. You’ll set up a join table for this association, which is a table that contains foreign key fields for each side of the association. A join table’s sole purpose is to join together the two tables whose keys it has. In this case, the two tables are the tickets and tags tables. As you move forward in developing this association, note that, for all intents and purposes, has_and_belongs_to_many works like a two-way has_many.