Skip to content

Instantly share code, notes, and snippets.

@ionas
Created December 27, 2010 19:23
Show Gist options
  • Select an option

  • Save ionas/756440 to your computer and use it in GitHub Desktop.

Select an option

Save ionas/756440 to your computer and use it in GitHub Desktop.
#http://stackoverflow.com/questions/373731/override-activerecord-attribute-methods
def price(option = nil)
if option == :nice
("%.2f" % price).gsub('.00', '.--').gsub('.', ',')
else
read_attribute(:price) # No test for nil?
end
end
# usage
# <%= product.price :nice %>&nbsp;&euro;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment