refinerycms-tip-of-the-day 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/tip.rb +5 -1
- data/db/migrate/create_tips.rb +1 -1
- metadata +2 -2
data/app/models/tip.rb
CHANGED
@@ -2,5 +2,9 @@ class Tip < ActiveRecord::Base
|
|
2
2
|
acts_as_indexed :fields => [:title]
|
3
3
|
validates_presence_of :title
|
4
4
|
validates_presence_of :content
|
5
|
-
|
5
|
+
|
6
|
+
def self.tip_of_the_day
|
7
|
+
offset = (Date.today.year + Date.today.day) % Tip.count
|
8
|
+
return Tip.find(:first,:offset => offset,:conditions => {:published => true}) rescue nil
|
9
|
+
end
|
6
10
|
end
|
data/db/migrate/create_tips.rb
CHANGED