blob: acf55fe4cdcc7c7f605d67f5e06e17966c7884cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
class Tutorial < ApplicationRecord
validates :url, presence: true
belongs_to :user
acts_as_taggable
default_scope -> { order('tutorials.created_at desc') }
scope :search, ->(query) do
query.blank? ? all : where(["UPPER(heading) LIKE :query OR UPPER(description) LIKE :query", { query: "%#{query.upcase}%" }])
end
def to_param
"#{id}-#{heading.parameterize}"
end
end
|