Sha256: dc4e6e6e9fd8e381733fcf9784c3d92b2ce47912d0abcbfec1ed08ef1ea3dcd9
Contents?: true
Size: 934 Bytes
Versions: 5
Compression:
Stored size: 934 Bytes
Contents
module Dorsale::CommentsHelper def comments_for(commentable) comments = policy_scope(::Dorsale::Comment).where(commentable: commentable) new_comment = new_comment_for(commentable) render( :partial => "dorsale/comments/comments", :locals => { :comments => comments, :new_comment => new_comment, }, ) end def new_comment_for(commentable) policy_scope(Dorsale::Comment).new(commentable: commentable, author: current_user) 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
5 entries across 5 versions & 1 rubygems