mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
slug memoization in the table
This commit is contained in:
parent
c9ed7100b1
commit
81673dcde8
1 changed files with 18 additions and 1 deletions
|
@ -598,7 +598,24 @@ class Topic < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def slug
|
||||
Slug.for(title).presence || "topic"
|
||||
unless slug = read_attribute(:slug)
|
||||
return '' unless title.present?
|
||||
slug = Slug.for(title).presence || "topic"
|
||||
if new_record?
|
||||
write_attribute(:slug, slug)
|
||||
else
|
||||
update_column(:slug, slug)
|
||||
end
|
||||
end
|
||||
|
||||
slug
|
||||
end
|
||||
|
||||
def title=(t)
|
||||
slug = ""
|
||||
slug = (Slug.for(t).presence || "topic") if t.present?
|
||||
write_attribute(:slug, slug)
|
||||
write_attribute(:title,t)
|
||||
end
|
||||
|
||||
def last_post_url
|
||||
|
|
Loading…
Reference in a new issue