search for: pic_tags

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

2010 Jan 15
1
Chaining queries in ActiveRecord
...t a simple search function, so that I can search for a picture with several 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....