search for: options_for_tag

Displaying 1 result from an estimated 1 matches for "options_for_tag".

2010 Jan 15
1
Chaining queries in ActiveRecord
...al given tags. Now say I want to search for pics that are tagged with "dog" and "cat". The simplest way to do this is to use named_scopes, for example: [code] class Pic < ActiveRecord::Base has_many :pic_tags has_many :tags, :through => :pic_tags named_scope :dog, options_for_tag(“dog") # options_for_tag(tag) is a method to generate joined table search conditions, not important named_scope :cat, options_for_tag("cat") end [/code] But when I chain the query like this: [code]Pic.dog.cat[/code] The SQL query that I''m actually getting is the merged co...