File tree 1 file changed +4
-1
lines changed
1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ class Protip < ActiveRecord::Base
19
19
20
20
scope :random , -> ( count = 1 ) { order ( "RANDOM()" ) . limit ( count ) }
21
21
scope :recently_created , -> ( count = 5 ) { order ( created_at : :desc ) . limit ( count ) }
22
- scope :recently_most_viewed , -> { order ( views_count : :desc ) . where ( public_id : %w{ ewk0mq kvzbpa vsdrug os6woq w7npmq _kakfa } ) }
22
+ scope :recently_most_viewed , -> { order ( views_count : :desc ) . where (
23
+ public_id : %w{ ewk0mq kvzbpa vsdrug os6woq w7npmq _kakfa } )
24
+ }
23
25
24
26
def to_param
25
27
self . public_id
@@ -81,6 +83,7 @@ def cacluate_score
81
83
end
82
84
83
85
def generate_public_id
86
+ return self . public_id if self . public_id
84
87
self . public_id = SecureRandom . urlsafe_base64 ( 4 ) . downcase
85
88
#retry if not unique
86
89
generate_public_id unless Protip . where ( public_id : self . public_id ) . blank?
You can’t perform that action at this time.
0 commit comments