Can I or SHOULD I find an object by the object_id attribute in ruby?

Yes, you can: irb(main):002:0> s1 = “foo” #=> “foo” irb(main):003:0> s2 = ObjectSpace._id2ref(s1.object_id) #=> “foo” irb(main):004:0> s2.object_id == s1.object_id #=> true irb(main):005:0> s2[0] = “z” #=> “z” irb(main):006:0> s1 #=> “zoo” Should you do this? I’ll leave that up to you. There are less geeky ways to store an object with a serializable id (e.g. … Read more

HABTM Relationship — How Can I Find A Record Based On An Attribute Of The Associated Model

You need to include the interests table. @events = Event.all(:include => :interests, :conditions => [“interests.id = ?”, 4]) You had it right in your post, but you didn’t pluralize interests. Update Because this answer is still getting attention, I thought it might be a good idea to update it using ActiveRecord::Relation syntax since the above … Read more