acts_as_commentable 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -58,6 +58,8 @@ Add multiple type of comments to a model:
58
58
  acts_as_commentable :public, :private
59
59
  end
60
60
 
61
+ *Note:* This feature is only available from version 4.0 and above
62
+
61
63
  Fetch comments for a this model:
62
64
 
63
65
  public_comments = Todo.find(1).public_comments
@@ -10,7 +10,7 @@ module ActsAsCommentable
10
10
  def self.included(comment_model)
11
11
  comment_model.extend Finders
12
12
  comment_model.scope :in_order, -> { comment_model.order('created_at ASC') }
13
- comment_model.scope :recent, -> { comment_model.order('created_at DESC') }
13
+ comment_model.scope :recent, -> { comment_model.reorder('created_at DESC') }
14
14
  end
15
15
 
16
16
  def is_comment_type?(type)
@@ -21,12 +21,13 @@ module Juixe
21
21
  if !comment_roles.blank?
22
22
  comment_roles.each do |role|
23
23
  has_many "#{role.to_s}_comments".to_sym,
24
+ -> { where(role: role.to_s) },
24
25
  {:class_name => "Comment",
25
26
  :as => :commentable,
26
27
  :dependent => :destroy,
27
- :conditions => ["role = ?", role.to_s],
28
28
  :before_add => Proc.new { |x, c| c.role = role.to_s }}
29
29
  end
30
+ has_many :all_comments, {:as => :commentable, :dependent => :destroy, class_name: "Comment"}
30
31
  else
31
32
  has_many :comments, {:as => :commentable, :dependent => :destroy}
32
33
  end
@@ -45,7 +46,7 @@ module Juixe
45
46
  end
46
47
 
47
48
  def #{method_name}_ordered_by_submitted
48
- Comment.find_comments_for_commentable(self.class.name, id, "#{role.to_s}")
49
+ Comment.find_comments_for_commentable(self.class.name, id, "#{role.to_s}").order("created_at")
49
50
  end
50
51
 
51
52
  def add_#{method_name.singularize}(comment)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_commentable
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -28,7 +28,6 @@ files:
28
28
  - lib/generators/comment/templates/comment.rb
29
29
  - lib/generators/comment/templates/create_comments.rb
30
30
  - lib/generators/comment/USEGA
31
- - tasks/acts_as_commentable_tasks.rake
32
31
  - init.rb
33
32
  - install.rb
34
33
  homepage: http://www.juixe.com/techknow/index.php/2006/06/18/acts-as-commentable-plugin/
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :acts_as_commentable do
3
- # # Task goes here
4
- # end