Sha256: c1c793463d0eefb2c599d7e2e1b25992e7ee05b2c11109aa951f7b2565e39fa2
Contents?: true
Size: 942 Bytes
Versions: 1
Compression:
Stored size: 942 Bytes
Contents
module Dorsale::CommentsHelper def comments_for(commentable, comments = nil) comments = ::Dorsale::Comment.where(commentable: commentable) if comments.nil? comments = policy_scope(comments).preload(:commentable, :author) new_comment = policy_scope(comments).new(commentable: commentable, author: current_user) render( :partial => "dorsale/comments/comments", :locals => { :comments => comments, :new_comment => new_comment, }, ) end def truncate_comments_in_this_page? controller_name == "people" end def truncate_comment_text(comment) text = comment.text.to_s truncated = false if text.to_s.count("\n") > 3 text = text.split("\n")[0, 3].join("\n") truncated = true end if text.to_s.length > 300 text = truncate(text, length: 200) truncated = true end text2html(text) if truncated end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dorsale-3.5.2 | app/helpers/dorsale/comments_helper.rb |