cavneb/make_flaggable — pull request #10 by eric-hu (2012-12-13 22:37:13+00:00)
Title: Add find_last_flag_for and find_all_flags_for methods to Flagger

I added two finder methods to the Flagger module. It looks like the philosophy of make_flaggable has been to abstract away the table details from the gem user. If that's the case, then my change deviates from that philosophy.

My reasoning for doing so is as follows:

- Flagging is done by the user
- An MVC design would have a Flag/Flagging controller to interact with the user
- A resourceful Flag controller would be most de-coupled from Flaggable classes if it just took a Flag id for a `destroy` method
- To find flags right now, I have code in my view that looks something like this:

```haml
- if current_user.flagged?(flaggable_item)
- flag = flaggable_item.flaggings.where(flagger_id: current_user.id)[0]
= link_to "Unflag this post", flag_path(flag), method: :delete
```

This change allows such code to be shortened to

```haml

- if current_user.flagged?(flaggable_item)
- flag = current_user.find_last_flag_for(flaggable_item)
= link_to "Unflag this post", flag_path(flag), method: :delete
```