residency/app/helpers/members_helper.rb
2023-06-18 11:23:46 +03:00

24 lines
579 B
Ruby

module MembersHelper
def picture_for(someone , classes = "")
if someone.picture.blank?
image = asset_url("no_image.png")
else
image = someone.picture.url
end
if someone.respond_to? :name
alt = someone.name
else
alt = ""
end
image_tag(image , alt: alt , class: classes )
end
def stayed(member)
return "Not arrived" if member.arriving.blank?
text = member.arriving.to_s
return text + " not left" if member.leaving.blank?
text + " " + distance_of_time_in_words( member.leaving , member.arriving)
end
end