Skip to content

Instantly share code, notes, and snippets.

@MyklClason
Last active March 20, 2022 00:44
Show Gist options
  • Save MyklClason/0b0cb17e5ca7569ec8ac709d87e3fc11 to your computer and use it in GitHub Desktop.
Save MyklClason/0b0cb17e5ca7569ec8ac709d87e3fc11 to your computer and use it in GitHub Desktop.
Pretty Helper
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