Module: Discussion::ThreadsHelper

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

Instance Method Summary collapse

Instance Method Details

#form_pathObject



30
31
32
# File 'app/helpers/discussion/threads_helper.rb', line 30

def form_path
  @threadable.present? ? main_app.polymorphic_url([@threadable, :threads]) : threads_path
end


19
20
21
22
# File 'app/helpers/discussion/threads_helper.rb', line 19

def link_to_destroy_thread(thread, options={}, &block)
  options = {method: :delete, data: {confirm: 'Are you sure?'}, link_text: 'Destroy'}
  link_to_thread(thread, options, &block)
end


24
25
26
27
28
# File 'app/helpers/discussion/threads_helper.rb', line 24

def link_to_new_thread(options={}, &block)
  path = @threadable.present? ? main_app.polymorphic_url([:new, @threadable, :thread]) : new_thread_path
  options = {remote: Discussion.ajaxify}.merge(options)
  link_to options[:link_text] || 'New Thread', path, options, &block
end


13
14
15
16
17
# File 'app/helpers/discussion/threads_helper.rb', line 13

def link_to_thread(thread, options={}, &block)
  path = @threadable.present? ? main_app.polymorphic_url([@threadable, thread]) : thread_path(thread)
  options = {remote: Discussion.ajaxify}.merge(options)
  link_to options[:link_text] || 'Threads', path, options, &block
end


3
4
5
6
# File 'app/helpers/discussion/threads_helper.rb', line 3

def link_to_threads(options={}, &block)
  options = {remote: Discussion.ajaxify}.merge(options)
  link_to options[:link_text] || 'Threads', path_to_threads(options), options, &block
end

#load_threads_for(topic, options = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/helpers/discussion/threads_helper.rb', line 34

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

#path_to_threads(options = {}) ⇒ Object



8
9
10
11
# File 'app/helpers/discussion/threads_helper.rb', line 8

def path_to_threads(options={})
  sent_item = options[:sent_item].nil? ? nil : (options[:sent_item] ? 'true' : 'false')
  @threadable.present? ? main_app.polymorphic_url([@threadable, :threads], sent_item: sent_item) : threads_path(sent_item: sent_item)
end