Lets say I have a Model A which has a 1 to 1 association with Model B. Model B is set to 'acts_as_taggable'. I would like to return an active record relation that selects all A instances who's B attribute is tagged_with a certain string. It would look something like: A.where('b.tagged_with = ?', 'some_tag')
I found this SO question, but i'm interested in getting an active record relation back so only the 2nd solution is applicable and I can't get it to work. How can I get back active record relations so I can call other query params methods on it ie. A.b_tagged_with('tag').where(...) where b_tagged_with is a named scope
to answer my own question, my scope definition in A looks like this:
What this says is return all A models whose b members are associated with a tagging if that taggings' tag association has a 'name' value equal to the param we passed in. In this example B 'acts_as_taggable', A doesn't. This allows me to do: