Class: Comment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Comment
- Defined in:
- lib/generators/acts_as_commentable_upgrade_migration/comment.rb,
lib/generators/acts_as_commentable_with_threading_migration/templates/comment.rb
Class Method Summary collapse
-
.build_from(obj, user_id, comment) ⇒ Object
Helper class method that allows you to build a comment by passing a commentable object, a user_id, and comment text example in readme.
-
.find_commentable(commentable_str, commentable_id) ⇒ Object
Helper class method to look up a commentable object given the commentable class name and id.
Instance Method Summary collapse
-
#has_children? ⇒ Boolean
helper method to check if a comment has children.
Class Method Details
.build_from(obj, user_id, comment) ⇒ Object
Helper class method that allows you to build a comment by passing a commentable object, a user_id, and comment text example in readme
19 20 21 22 23 24 |
# File 'lib/generators/acts_as_commentable_upgrade_migration/comment.rb', line 19 def self.build_from(obj, user_id, comment) new \ :commentable => obj, :body => comment, :user_id => user_id end |
.find_commentable(commentable_str, commentable_id) ⇒ Object
Helper class method to look up a commentable object given the commentable class name and id
45 46 47 |
# File 'lib/generators/acts_as_commentable_upgrade_migration/comment.rb', line 45 def self.find_commentable(commentable_str, commentable_id) commentable_str.constantize.find(commentable_id) end |
Instance Method Details
#has_children? ⇒ Boolean
helper method to check if a comment has children
27 28 29 |
# File 'lib/generators/acts_as_commentable_upgrade_migration/comment.rb', line 27 def has_children? self.children.size > 0 end |