ismasan-ar_publish_control 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/ar_publish_control.gemspec +1 -1
- data/lib/ar_publish_control.rb +3 -2
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -100,7 +100,7 @@ Add the necessary fields to you schema, in a migration:
|
|
100
100
|
|
101
101
|
class AddPublishableToPosts < ActiveRecord::Migration
|
102
102
|
def self.up
|
103
|
-
add_column :posts, :is_published, :boolean
|
103
|
+
add_column :posts, :is_published, :boolean, :default => true
|
104
104
|
add_column :posts, :publish_at, :datetime
|
105
105
|
add_column :posts, :unpublish_at, :datetime
|
106
106
|
end
|
data/ar_publish_control.gemspec
CHANGED
data/lib/ar_publish_control.rb
CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
4
|
module ArPublishControl
|
5
|
-
VERSION = '0.0.
|
5
|
+
VERSION = '0.0.6'
|
6
6
|
# This is a gem version of http://github.com/avdgaag/acts_as_publishable ( a Rails plugin)
|
7
7
|
# Thanks to Avdaag for his awesome, super readable code which I ripped off for this gem.
|
8
8
|
#
|
@@ -101,6 +101,7 @@ module ArPublishControl
|
|
101
101
|
bool ? {:conditions => published_conditions} : {}
|
102
102
|
}
|
103
103
|
before_validation :init_publish_date # don't allow empty publish_at
|
104
|
+
validate :validate_publish_date_consistency
|
104
105
|
before_create :publish_by_default if options[:publish_by_default]
|
105
106
|
end
|
106
107
|
|
@@ -163,7 +164,7 @@ module ArPublishControl
|
|
163
164
|
|
164
165
|
# Validate that unpublish_at is greater than publish_at
|
165
166
|
# publish_at must not be nil
|
166
|
-
def
|
167
|
+
def validate_publish_date_consistency
|
167
168
|
if unpublish_at && publish_at && unpublish_at <= publish_at
|
168
169
|
errors.add(:unpublish_at,"should be greater than publication date or empty")
|
169
170
|
end
|