Class: Comment

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Bravo::Comment
Defined in:
lib/generators/comment/templates/app/models/comment.rb

Class Method Summary collapse

Methods included from Bravo::Comment

included

Class Method Details

.search(query) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/generators/comment/templates/app/models/comment.rb', line 14

def self.search(query)
  if query.blank?
    scoped
  else
    conditions = %w[content].map { |c| "comments.#{c} like :query" }
    where(conditions.join(" or "),:query => "%#{query}%")
  end
end