ActiveRecord find by full name scope

scope :find_by_full_name, lambda { |full_name| { :conditions => ["name LIKE ? or last_name LIKE ?", "%#{full_name.split(' ').first}%", "%#{full_name.split(' ').last}%"] } }
You can use this to find un your model by full_name without using full_text search.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.