Skip to content

Instantly share code, notes, and snippets.

@jeremy6d
Created March 12, 2014 16:14
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 jeremy6d/9510253 to your computer and use it in GitHub Desktop.
Save jeremy6d/9510253 to your computer and use it in GitHub Desktop.
Defining a method on a model attribute within its accessor
# note that 'tags' is an array attribute in Mongoid
def tags
read_attribute(name).tap do |array|
def array.to_s
join(", ")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment