Module: Sunrise::ActivitiesHelper
- Defined in:
- app/helpers/sunrise/activities_helper.rb
Instance Method Summary collapse
- #activity_icon_tag(key, options = {}) ⇒ Object
-
#link_to_trackable(object, object_type) ⇒ Object
Check if object still exists in the database and display a link to it, otherwise display a proper message about it.
-
#timeago_tag(time, options = {}) ⇒ Object
For generating time tags calculated using jquery.timeago.
Instance Method Details
#activity_icon_tag(key, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/sunrise/activities_helper.rb', line 10 def activity_icon_tag(key, = {}) icon = key.split('.').last image = image_path("sunrise/icons/#{icon}.svg") = { :class => "mega-icon", :style => "background-image: url(#{image});" }.merge() content_tag(:div, nil, ) end |
#link_to_trackable(object, object_type) ⇒ Object
Check if object still exists in the database and display a link to it, otherwise display a proper message about it. This is used in activities that can refer to objects which no longer exist, like removed posts.
26 27 28 29 30 31 32 33 34 |
# File 'app/helpers/sunrise/activities_helper.rb', line 26 def link_to_trackable(object, object_type) model_name = object_type.downcase if object link_to(model_name, edit_path(:model_name => model_name.pluralize, :id => object.id)) else "a #{model_name} which does not exist anymore" end end |
#timeago_tag(time, options = {}) ⇒ Object
For generating time tags calculated using jquery.timeago
5 6 7 8 |
# File 'app/helpers/sunrise/activities_helper.rb', line 5 def timeago_tag(time, = {}) [:class] ||= "timeago" content_tag(:abbr, time.to_s, .merge(:title => time.getutc.iso8601)) if time end |