Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1028171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:20:48+00:00 2026-05-16T12:20:48+00:00

So Candy is a really simple library for interacting with Mongo in Ruby. My

  • 0

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 users, there are things. Each thing was made by one user, but should be accessible to a subset of all users (specified within the thing). Leaving the specification of user out of the way for now, how would I get a list of all things 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 users to a thing like this? (lets just use strings to reference users 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:20:48+00:00Added an answer on May 16, 2026 at 12:20 pm

    I’m really sorry I took so long to catch this and respond. This might be too late for your purposes, but:

    Candy doesn’t implement a find method. This is on purpose: if an object represents a collection, every access is implicitly finding something in that collection. It’s the same reason there is no save method. If the mapping is truly transparent, verbs that mean “Do this in the database” shouldn’t be necessary.

    So to do what you want, you could either just make a new Things object with the scope passed on creation:

    x_is_allowed = Things.new(allowed: 'X')
    

    …or you could save a step and do it by class method:

    x_is_allowed = Things.allowed('X')
    

    …or you could start with the whole collection and limit it by attribute later:

    things = Things.new
    x_is_allowed = things.allowed('X')
    

    So… Um. All of those will work. But. I have to warn you that I’m really not happy with the general usability of Candy right now, and of collections and array fields in particular. The biggest problem is accessors: the [] method isn’t working like you’d expect, so you end up having to call to_a and refresh and other things that feel sticky and unpleasant.

    This needs to be fixed, and I will do so as soon as I finish the driver rewrite (a related project called Crunch). In the short term, Candy is probably best viewed as an experiment for the adventurous, and I can’t guarantee it’ll save time until the interface is locked down a bit better. I’m sorry about that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The bootstrap based maven-fluido-skin skin is eye candy but I cannot figure out how
I really cannot figure out how to format double/decimal value like that 12,123,123.78 Here
I'm creating a simple application, first time working with SQLite. I want a regular
I have searched for some time investigating several technologies to build an simple instant
Say i have those 3 arrays : Product(milk,candy,chocolate) Colors(white,red,black) Rating(8,7,9) How to create a
I'm looking for preferably javascript (but flash would do too) charting library which would
There are some eye-candy experimental CSS like border-radius (rounded corners) and gradients that I
I rather enjoy adding practical eye-candy to the networking community I've been developing but
I have the following XML: <record> <fruit>Apples</fruit> <fruit>Oranges</fruit> <fruit>Bananas</fruit> <fruit>Plums</fruit> <vegetable>Carrots</vegetable> <vegetable>Peas</vegetable> <candy>Snickers</candy> </record>
I have some Clojure code that seems maddeningly simple and yet is throwing an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.