Module: PublicActivity::ViewHelpers

Defined in:
lib/public_activity/utility/view_helpers.rb

Overview

Module extending ActionView::Base and adding ‘render_activity` helper.

Instance Method Summary collapse

Instance Method Details

#render_activity(activities, options = {}) ⇒ Object Also known as: render_activities

View helper for rendering an activity, calls Activity#render internally.



8
9
10
11
12
13
14
15
16
# File 'lib/public_activity/utility/view_helpers.rb', line 8

def render_activity activities, options = {}
  if activities.is_a? PublicActivity::Activity
    activities.render self, options
  elsif activities.respond_to?(:map)
    # depend on ORMs to fetch as needed
    # maybe we can support Postgres streaming with this?
    activities.map {|activity| activity.render self, options.dup }.join.html_safe
  end
end

#single_content_for(name, content = nil, &block) ⇒ Object

Helper for setting content_for in activity partial, needed to flush remains in between partial renders.



21
22
23
24
# File 'lib/public_activity/utility/view_helpers.rb', line 21

def single_content_for(name, content = nil, &block)
  @view_flow.set(name, ActiveSupport::SafeBuffer.new)
  content_for(name, content, &block)
end