Created
February 15, 2023 05:24
-
-
Save richlow/f1ea7196567798d8c1753670aa6838b9 to your computer and use it in GitHub Desktop.
Revisions
-
richlow created this gist
Feb 15, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ ################################# # Pre-req: install font awesome (fonts) ################################# #star_rating_helper.rb module StarRatingHelper def star_rating(rating) full_star = "fas fa-star" empty_star = "far fa-star" stars = [] for i in 1..5 if i <= rating stars << full_star else stars << empty_star end end stars.map do |star| content_tag(:i, "", class: star) end.join("\n").html_safe end end ################################# You call this in the view file <%= star_rating(space.rank) %>