Created
March 12, 2014 16:14
-
-
Save jeremy6d/9510253 to your computer and use it in GitHub Desktop.
Defining a method on a model attribute within its accessor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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