biola/buweb-content-models — pull request #116 by halloffame (2014-09-18 23:52:20+00:00)
Title: Adding tags

A `mettable` object can have one `meta_data`. That `meta_data` has a unique slug that is used to identify it.

Other objects can be related to the first object by adding its `meta_data.slug` to their `related_slugs` array.

```ruby
# relate object_b to object_a through object_a's meta_data slug
object_b.related_slugs << object_a.meta_data.slug

# find all departments that are related to object_a
Department.by_related_slugs('object-a-meta-data-slug')

# You can also pass in an array of multiple slugs and find departments matching at least one.
Department.by_related_slugs(['object-a-meta-data-slug', 'some-other-slug'])
```

Here's a diagram if that helps at all...
![drawing](https://cloud.githubusercontent.com/assets/957859/4328975/7b9176b4-3f8e-11e4-94e0-143c834f4d44.png)