Sha256: 4dde19640a6c8bb2a168c7ef0edb597bc15faee32216cac98c7efe3098f5f005
Contents?: true
Size: 942 Bytes
Versions: 37
Compression:
Stored size: 942 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? params[:controller].include?("customer_vault") end def truncate_comment_text(text) text = 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
37 entries across 37 versions & 1 rubygems