Module: ActivitiesHelper
- Defined in:
- app/helpers/activities_helper.rb
Instance Method Summary collapse
- #activity_css_classes(activity) ⇒ Object
- #activity_datetime(activity, short = false) ⇒ Object
- #activity_object_edit_url(activity) ⇒ Object
-
#link_to_activity_user(activity) ⇒ Object
FIXME not used anywhere? def link_to_activity_commentable(activity) link_to truncate(activity.commentable_title, 100), activity_commentable_url(activity) end.
- #render_activities(activities, recent = false) ⇒ Object
Instance Method Details
#activity_css_classes(activity) ⇒ Object
14 15 16 17 18 |
# File 'app/helpers/activities_helper.rb', line 14 def activity_css_classes(activity) type = activity.object_attributes['type'] || activity.object_type "#{type}_#{activity.all_actions.last}".downcase # activity.all_actions.collect {|action| "#{type}-#{action}".downcase }.uniq * ' ' end |
#activity_datetime(activity, short = false) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/activities_helper.rb', line 20 def activity_datetime(activity, short = false) if activity.from and short from = activity.from.to_fs(:time_only) to = activity.to.to_fs(:time_only) "#{from} - #{to}" elsif activity.from and activity.from.to_date != activity.to.to_date from = activity.from.to_fs(:long_ordinalized) to = activity.to.to_fs(:long_ordinal) "#{from} - #{to}" elsif activity.from from = activity.from.to_fs(:long_ordinal) to = activity.to.to_fs(:time_only) "#{from} - #{to}" else activity.created_at.to_fs(short ? :time_only : :long_ordinal) end end |
#activity_object_edit_url(activity) ⇒ Object
38 39 40 41 |
# File 'app/helpers/activities_helper.rb', line 38 def activity_object_edit_url(activity) type = activity.object_attributes['type'] || activity.object_type send "edit_admin_#{type}_path".downcase, activity.site_id, activity.section_id, activity.object_id end |
#link_to_activity_user(activity) ⇒ Object
FIXME not used anywhere? def link_to_activity_commentable(activity)
link_to truncate(activity.commentable_title, 100), activity_commentable_url(activity)
end
54 55 56 57 58 59 60 |
# File 'app/helpers/activities_helper.rb', line 54 def link_to_activity_user(activity) if activity..registered? link_to activity., admin_user_path(activity.) else activity.(:include_email => true) end end |
#render_activities(activities, recent = false) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'app/helpers/activities_helper.rb', line 2 def render_activities(activities, recent = false) if activities.present? html = activities.collect do |activity| render :partial => "admin/activities/#{activity.object_type.downcase}", :locals => { :activity => activity, :recent => recent } end.join else html = %(<li class="empty shade">Nothing happened.</li>) end raw %(<ul class="activities">#{html}</ul>) end |