volunteers/app/helpers/members_helper.rb

27 lines
626 B
Ruby
Raw Normal View History

2022-12-20 16:05:26 +01:00
module MembersHelper
2023-01-11 17:20:21 +01:00
def picture_for(someone , classes = "")
2023-02-02 11:48:33 +01:00
image = someones_path(someone)
2023-01-25 21:15:54 +01:00
if someone.respond_to? :name
alt = someone.name
else
alt = ""
end
image_tag(image , alt: alt , class: classes )
2023-01-11 17:20:21 +01:00
end
2023-02-02 11:48:33 +01:00
def someones_path( someone )
if someone.picture.blank?
asset_url("no_image.png")
else
someone.picture.url
end
end
2023-01-12 13:56:50 +01: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 21:24:36 +01:00
text + " " + distance_of_time_in_words( member.left , member.arrived)
2023-01-12 13:56:50 +01:00
end
2022-12-20 16:05:26 +01:00
end