Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
##acts_as_xapian tip - using with association proxies ##Named scope class Lesson < ActiveRecord::Base named_scope :find_with_xapian, lambda { |*args| {:conditions => ["lessons.id in (?)", ActsAsXapian::Search.new([Lesson], args.to_s).results.collect{|x| x[:model].id}]}} end ##But if we do this instead, we can now do association proxies class Lesson < ActiveRecord::Base def self.find_with_xapian(search_term, options={}) ActsAsXapian::Search.new([self], search_term, options).results.collect{|x| x[:model]} end end current_user.lessons.find_with_xapian "something" ##That would automatically scope and return lessons that belong to the current user only. Awesome!
This paste will be private.
From the Design Piracy series on my blog: