Pastable version of Rails helper method needs refactoring