With association extensions, like user.items.tagged(“foo”), how do I
access the “user” object from within the extension method? The code
would be e.g.
class User < ActiveRecord::Base
has_and_belongs_to_many :items do
return “These are items tagged %s from user %s.” % [tag, ???]
but how would I get a hold of the user in question, within that method?
Since “self” in the method refers to the “items” collection, I can do
self.user, but that seems very much like a hack, and will obviously
not work if the items collection is empty.