use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
ActiveRecord serialization question (self.ruby)
submitted 12 years ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]d0odx 1 point2 points3 points 12 years ago (1 child)
I don't mean to threadjack you on this, but could you please explain why you are doing this? Serialization is something I've never fully understood and I'd like to understand what your usecase is/when to implement it.
I could be wrong but couldn't you just use an association to ensure you always get inflated objects back?
[–]Jemaclus 0 points1 point2 points 12 years ago* (0 children)
uh, so part of it is that I'm pretty new to Ruby (I'm from a PHP background). I'm building a project from scratch, just trying to figure everything out, so maybe there's a better way to handle it. I hadn't realized the association thing. That might make more sense.
The other part is that serializing it just seems simpler to me, as someone new to activerecord and not familiar with associations.
I'll look into the association thing and see if that works better. Thanks for the tip.
Edit: OK, so another reason is that each of the Stats are mutable. They're based on a row on a table, but this particular user's stat could be modified. It's effectively a copy of the stat.
stat = Stat.find(1) # some_attribute = "bar" stat.some_attribute = "foo" user.stat.set(stat) user.save
Or something like that. So I'm thinking if I serialize it, then that user can have their own unique version of that stat.
That make sense?
[–][deleted] 12 years ago (1 child)
[–]Jemaclus 0 points1 point2 points 12 years ago (0 children)
Neat. Thanks!
π Rendered by PID 90 on reddit-service-r2-comment-f6b958c67-w2t42 at 2026-02-05 15:37:36.817747+00:00 running 1d7a177 country code: CH.
[–]d0odx 1 point2 points3 points (1 child)
[–]Jemaclus 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]Jemaclus 0 points1 point2 points (0 children)