On Feb 15, 2010, at 9:31 PM, Chris Dempsey wrote:
I would like to be able to save a set of age brackets as a range and
have it treated as a Ruby range when retrieved from the database.
I've done quite a bit of searching (maybe my Google-fu just sucks)
but haven't had any luck in getting to an answer. Anyone have any
thoughts on doing this or should I simply save the minimum / maximum
and roll my own range-like methods?
You could use serialize
class Person
serialize :age_range
end
teenager = Person.create(:age_range => 13..19)
But be aware that the actual field in the table will be a YAML-ized
representation as a string.
-Rob
Rob Biedenharn http://agileconsultingllc.com
r...@agileconsultingllc.com
--
You received this message because you are subscribed to the Google Groups "Ruby on
Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.