Permalink
Browse files

Moved search logic into a named scope for Translation

  • Loading branch information...
1 parent 9d5e546 commit 1a6ba4bba7a3f2bbf0f0f5e6562f094bcb45b269 Liborio Cannici committed May 16, 2010
Showing with 4 additions and 0 deletions.
  1. +4 −0 app/models/tolk/translation.rb
@@ -2,6 +2,10 @@ module Tolk
class Translation < ActiveRecord::Base
set_table_name "tolk_translations"
+ named_scope :containing_text, lambda { |query|
+ { :conditions => ["tolk_translations.text LIKE ?", "%#{query}%"] }
+ }
+
serialize :text
validates_presence_of :text, :if => proc {|r| r.primary.blank? && !r.explicit_nil }

0 comments on commit 1a6ba4b

Please sign in to comment.