AutoCommit Fre Jul 31 21:03:04 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-07-31 21:03:04 +02:00
26 changed files with 340 additions and 23 deletions

20
lib/is_commentable.rb Normal file
View File

@@ -0,0 +1,20 @@
module IsCommentable
def self.included(base)
base.class_eval do
include InstanceMethods
has_many :comments, as: :commentable, dependent: :destroy
# extend ClassMethods
end
end
module InstanceMethods
def is_commentable?
true
end
def comment(user, text, attr={})
comments << Comment.build_for(self, user, text, attr)
end
end
end