docbrown/app/helpers/admin_helper.rb
Andy Zhao 8a7e5a5566
Escape periods and display the group name properly (#15819)
* Escape periods and display the group name properly

* Rename method to dom_safe_name and move to admin helper

* Replace beginning of string digit with underscore then digit
2021-12-17 17:35:42 -05:00

17 lines
344 B
Ruby

module AdminHelper
def deduced_controller(request)
request.path.split("/").fourth
end
def deduced_scope(request)
request.path.split("/").third
end
def display_name(group_name)
group_name.to_s.tr("_", " ").titleize
end
def dom_safe_name(group_name)
group_name.gsub(/\s+|\./, "_").gsub(/\A(\d)/, '_\1')
end
end