Module: Discussion::CommentsHelper

Defined in:
app/helpers/discussion/comments_helper.rb

Instance Method Summary collapse

Instance Method Details

#load_comments_for(commentable, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/helpers/discussion/comments_helper.rb', line 3

def load_comments_for(commentable, options={})
  remote = options[:remote] || false
  comments_container_id = "comments-#{Time.now.to_i}"
  if remote
    <<-EOF.html_safe
    <div id='#{comments_container_id}' class="comments_container">Loading comments ...</div>
    <script type='text/javascript'>
      Disussion.loadComments('#{polymorphic_url([commentable, :comments])}', '#{comments_container_id}');
    </script>
    EOF
  else
     :div, id: comments_container_id do
      render :partial => "discussion/comments/list_with_form", locals: {commentable: commentable, contriner_id: comments_container_id}
    end
  end
end