review_and_approve 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -33,6 +33,14 @@ class Product < ActiveRecord::Base
33
33
  end
34
34
  ```
35
35
 
36
+ In your form.html.erb
37
+ ```ruby
38
+ <div class="field">
39
+ <%= f.check_box :publish %>
40
+ <%= f.label :publish %>
41
+ </div>
42
+ ```
43
+
36
44
  To mark existing data as published:
37
45
 
38
46
  $ bundle exec rake review_and_approve:create_caches
@@ -61,12 +61,16 @@ module ReviewAndApprove
61
61
  CacheRecord.find_by_key("#{key_proc.call(self, method_name)}_current_version").cache_data rescue nil
62
62
  end
63
63
 
64
-
65
64
  send(:define_method, :mass_assignment_authorizer) do |role = :default|
66
65
  # force add the :publish attribute into attr_accessible
67
66
  super(role) + [field]
68
67
  end
69
68
 
69
+ # Check if a record has been published before.
70
+ send(:define_method, :published?) do
71
+ CacheRecord.where("key = '#{key_proc.call(self, methods.first)}_published_version'").count>0
72
+ end
73
+
70
74
  validates_each field do |record, attr, value|
71
75
  able = Thread.current[:reviewAndApprove_current_ability].try(:can?, :publish, record)
72
76
  # if user can not publish the record, create an error.
@@ -1,3 +1,3 @@
1
1
  module ReviewAndApprove
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: review_and_approve
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.6
5
+ version: 0.0.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Paramveer Singh
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2013-05-29 00:00:00 Z
13
+ date: 2013-07-31 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec