Module: Discussion::ThreadsHelper
- Defined in:
- app/helpers/discussion/threads_helper.rb
Instance Method Summary collapse
- #form_path ⇒ Object
- #link_to_destroy_thread(thread, options = {}, &block) ⇒ Object
- #link_to_new_thread(options = {}, &block) ⇒ Object
- #link_to_thread(thread, options = {}, &block) ⇒ Object
- #link_to_threads(options = {}, &block) ⇒ Object
- #load_threads_for(topic, options = {}) ⇒ Object
- #path_to_threads(options = {}) ⇒ Object
Instance Method Details
#form_path ⇒ Object
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 |
#link_to_destroy_thread(thread, options = {}, &block) ⇒ Object
19 20 21 22 |
# File 'app/helpers/discussion/threads_helper.rb', line 19 def link_to_destroy_thread(thread, ={}, &block) = {method: :delete, data: {confirm: 'Are you sure?'}, link_text: 'Destroy'} link_to_thread(thread, , &block) end |
#link_to_new_thread(options = {}, &block) ⇒ Object
24 25 26 27 28 |
# File 'app/helpers/discussion/threads_helper.rb', line 24 def link_to_new_thread(={}, &block) path = @threadable.present? ? main_app.polymorphic_url([:new, @threadable, :thread]) : new_thread_path = {remote: Discussion.ajaxify}.merge() link_to [:link_text] || 'New Thread', path, , &block end |
#link_to_thread(thread, options = {}, &block) ⇒ Object
13 14 15 16 17 |
# File 'app/helpers/discussion/threads_helper.rb', line 13 def link_to_thread(thread, ={}, &block) path = @threadable.present? ? main_app.polymorphic_url([@threadable, thread]) : thread_path(thread) = {remote: Discussion.ajaxify}.merge() link_to [:link_text] || 'Threads', path, , &block end |
#link_to_threads(options = {}, &block) ⇒ Object
3 4 5 6 |
# File 'app/helpers/discussion/threads_helper.rb', line 3 def link_to_threads(={}, &block) = {remote: Discussion.ajaxify}.merge() link_to [:link_text] || 'Threads', path_to_threads(), , &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, ={}) remote = [:remote] || false threads_container_id = "threads-#{Time.now.to_i}" if remote <<-EOF.html_safe <div id='#{threads_container_id}' class="comments_container"></div> <script type='text/javascript'> Disussion.loadComments('#{polymorphic_url([topic, :threads])}', '#{threads_container_id}'); </script> EOF else content_tag :div, id: comments_container_id do render :partial => "discussion/comments/list_with_form", locals: {commentable: commentable, contriner_id: comments_container_id} end end end |
#path_to_threads(options = {}) ⇒ Object
8 9 10 11 |
# File 'app/helpers/discussion/threads_helper.rb', line 8 def path_to_threads(={}) sent_item = [:sent_item].nil? ? nil : ([:sent_item] ? 'true' : 'false') @threadable.present? ? main_app.polymorphic_url([@threadable, :threads], sent_item: sent_item) : threads_path(sent_item: sent_item) end |