Is there a specific reason I need the self in this model’s method? I’m accessing it from another controller.
def self.search(query)
if query
find(:all, conditions: ['lower(first_name) LIKE ? OR lower(last_name) LIKE ?', "%#{query.downcase}%", "%#{query.downcase}%"])
else
find(:all)
end
end
In ruby, self is used for class methods (as opposed to instance methods), which are equivalent to static methods in other languages.
Example: