Last active
March 20, 2022 00:44
-
-
Save MyklClason/0b0cb17e5ca7569ec8ac709d87e3fc11 to your computer and use it in GitHub Desktop.
Pretty Helper
This file contains 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 characters
module PrettyHelper | |
def pretty_boolean(boolean) | |
boolean ? "Yes" : "No" | |
end | |
def pretty_array(array, seperator: ";") | |
array.to_a.join("; ") | |
end | |
def pretty_linked_record_array(array, field, new_window: true) | |
link_params = {} | |
link_params[:target] = "_blank" if new_window | |
sanitize array.to_a.map { |v| link_to(v.send(field), v, link_params) }.join(", "), attributes: %w(href target) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment