Created
October 27, 2010 20:11
-
-
Save duff/649855 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An account has payment methods. I'd like to know the payment methods for an account | |
# which meet some criteria. | |
# The 2 models | |
class Account | |
include Ripple::Document | |
many :payment_methods | |
end | |
class PaymentMethod | |
include Ripple::Document | |
one :account | |
property :storage_state, String | |
end | |
# In Active Record I can do the following: | |
account = Account.first | |
account.payment_methods.retained | |
# since there can be a named scope such as: | |
class PaymentMethod | |
scope :retained, :conditions => [ "storage_state = ?", "retained" ] | |
end | |
# I'm wondering what the best way might be to do this in Riak. |
Can I expect a pull request from you soon? hint hint
We'll see! I've been a bit surprised how little querying I've needed to do for the app I'm working on. At this point, I'm in "get some things working" mode. I'm now querying for strings and dates. I don't yet have enough real uses of querying in real apps to have a worthy pull request ready. I would think that would change over time. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OK. Got it working! Now it's time to clean it up.
Thanks Sean!