Skip to content

Instantly share code, notes, and snippets.

@oojikoo-gist
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oojikoo-gist/6c8104657995038c24ab to your computer and use it in GitHub Desktop.
Save oojikoo-gist/6c8104657995038c24ab to your computer and use it in GitHub Desktop.
rails: how to overwrite get and set methods

ActiveRecord: override how we access field

def length=(minutes)
  self[:length] = minutes * 60
end

def length
  self[:length] / 60
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment