volunteers/app/helpers/members_helper.rb

24 lines
570 B
Ruby
Raw Normal View History

2022-12-20 17:05:26 +02:00
module MembersHelper
2023-01-11 18:20:21 +02:00
def picture_for(someone , classes = "")
2023-01-11 18:20:21 +02:00
if someone.picture.blank?
2023-01-12 22:24:36 +02:00
image = asset_url("no_image.png")
2023-01-11 18:20:21 +02:00
else
2023-01-11 20:52:58 +02:00
image = someone.picture.url
2023-01-11 18:20:21 +02:00
end
2023-01-25 22:15:54 +02:00
if someone.respond_to? :name
alt = someone.name
else
alt = ""
end
image_tag(image , alt: alt , class: classes )
2023-01-11 18:20:21 +02:00
end
2023-01-12 14:56:50 +02:00
def stayed(member)
return "Not arrived" if member.arrived.blank?
text = member.arrived.to_s
return text + " not left" if member.left.blank?
2023-01-12 22:24:36 +02:00
text + " " + distance_of_time_in_words( member.left , member.arrived)
2023-01-12 14:56:50 +02:00
end
2022-12-20 17:05:26 +02:00
end