robinjohnobrien
robinjohnobrien

Reputation: 1092

Redis-objects list on a Redis-object in ruby

I have a redis-object's list. Each object in the list needs to have another list.

class Parent include Redis::Objects list :children, marshal: true end

class children include Redis::Objects end

The above code samples just highlight the relationship. They do include other things like attr_accessors etc.

My issue arrives when I call children on an instance of the parent, such as in the example below:

p = Parent.new

Redis::List.new('some_key', marshal: true) << p

p.children => nil

I have a working example using an active record model with the list added to it. However including it on a redis-object seems to give me issues.

Do I need to handle the situation manually in the way it is described in part two of the redis-object documentation, or do I some how have to create the redis-objects list on creation of the parent object? My thoughts were that this creation was implicit

Upvotes: 0

Views: 161

Answers (1)

robinjohnobrien
robinjohnobrien

Reputation: 1092

Solved. I had an attr_accessor on the parent, named children. This clashed with the list defined with the name children. Removing the attr_accessor resulted in the an empty redis-objects list being returned, which was the expected behavior.

Upvotes: 0

Related Questions