So Candy is a really simple library for interacting with Mongo in Ruby.
My poor SQL brain is having a tough time figuring out how I should map out this problem:
There are user
s, there are thing
s. Each thing
was made by one user
, but should be accessible to a subset of all user
s (specified within the thing
). Leaving the specification of user
out of the way for now, how would I get a list of all thing
s that user
X has access to?
class Thing
include Candy::Piece
end
class Things
include Candy::Collection
collects :thing
end
Should I assign the allowed user
s to a thing
like this? (lets just use strings to reference user
s for now)
t = Thing.new
t.allowed = ['X','Y','Z']
This seems about right to me, which would make me want to do:
Things.find(allowed:'X')
but it's not quite working…
NoMethodError: undefined method ‘call’ for {:allowed=>"X"}:Hash
any ideas?