// Sample Model /////////////// class Article < ActiveRecord::Base belongs_to :article_type belongs_to :filter acts_as_taggable set_cached_tag_list_column_name "cached_tag_list" acts_as_slugable :source_column => :title, :target_column => :url_slug validates_presence_of :title, :body named_scope :feed, lambda { |*args| { :limit => args.first, :order => 'created_at DESC', :conditions => ["article_type_id = 1 AND publish = 1"]} } named_scope :articles_for_sidebar, :select => "strftime('%Y', created_at) as year, strftime('%m', created_at) as month, COUNT(*) as total", :conditions => ["article_type_id = 1 AND publish = 1"], :group => "strftime('%Y', created_at), strftime('%m', created_at)", :order => "strftime('%Y', created_at) DESC, strftime('%m', created_at) DESC", :limit => 12 named_scope :search_articles, lambda { |*args| { :conditions => ["title||body||cached_tag_list like '%#{args.first}%' article_type_id = 1 AND publish = 1"]} } after_save :fix_booleans def fix_booleans # changes sqlite 't' / 'f' values to common integers end def self.find_pages_for_sitemap find(:all, :select => 'id, title, url_slug, created_at, updated_at' , :order => 'title' , :conditions => ["article_type_id = 2 AND publish = 1"], :limit => 50000) end