mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 03:07:52 +01:00
Add search to post list
This commit is contained in:
@@ -6,4 +6,10 @@ class Post < ApplicationRecord
|
||||
validates :title, presence: true, length: { in: 4..64 }
|
||||
|
||||
paginates_per 15
|
||||
|
||||
def self.search(s = '')
|
||||
s = s || ''
|
||||
s = sanitize_sql_like(s)
|
||||
where("posts.title ILIKE ? OR posts.description ILIKE ?", "%#{s}%", "%#{s}%")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user