Re: Ripple & an attribute named 'key'

2011-02-12 Thread Sean Cribbs
For future reference: https://github.com/seancribbs/ripple/blob/master/ripple/lib/ripple/document/key.rb Sean Cribbs Developer Advocate Basho Technologies, Inc. http://basho.com/ On Feb 12, 2011, at 10:56 PM, Mat Ellis wrote: > Lol. Ripple is wonderful, don't blame us for thinking it's magic ;-

Re: Ripple & an attribute named 'key'

2011-02-12 Thread Mat Ellis
Lol. Ripple is wonderful, don't blame us for thinking it's magic ;-) Thx this is very helpful. M. On Feb 12, 2011, at 7:55 PM, Sean Cribbs wrote: > Well, when it comes down to it, it's just a method. There's a lot less magic > in Ripple than you'd think. Try this: > > def key > @key ||= UUI

Re: Ripple & an attribute named 'key'

2011-02-12 Thread Sean Cribbs
Well, when it comes down to it, it's just a method. There's a lot less magic in Ripple than you'd think. Try this: def key @key ||= UUID.new # Replace with whatever you want, as long as it's a String end Sean Cribbs Developer Advocate Basho Technologies, Inc. http://basho.com/ On Feb 12, 20

Re: Ripple & an attribute named 'key'

2011-02-12 Thread Mat Ellis
Yep, exactly. But it doesn't appear until I save right? I'd prefer not to have that dependency. Is there a way round? M. On Feb 12, 2011, at 7:51 PM, Sean Cribbs wrote: > If you don't specify a key, Riak will choose one for you (base 62-encoded > hash of something, last I checked). Is that not

Re: Ripple & an attribute named 'key'

2011-02-12 Thread Sean Cribbs
If you don't specify a key, Riak will choose one for you (base 62-encoded hash of something, last I checked). Is that not what you're trying to do? Sean Cribbs Developer Advocate Basho Technologies, Inc. http://basho.com/ On Feb 12, 2011, at 10:50 PM, Mat Ellis wrote: > The point of the code i

Re: Ripple & an attribute named 'key'

2011-02-12 Thread Mat Ellis
The point of the code is not to use a non-string ID but to generate a default. Is it 'failing' because we're attempting to override the type? The actual code in question (this is a simplification) is generating a GUID which can easily be stored as a string instead of an integer. Otherwise we'll

Re: Ripple & an attribute named 'key'

2011-02-12 Thread Sean Cribbs
The choice of "key" as the method/attribute name corresponds to the Riak terminology for the same concept (and is analogous to "id" in ActiveRecord). If you want to use a non-String value for the key, create a property of some other name and then use the "key_on" method which makes a defined pr

Ripple & an attribute named 'key'

2011-02-12 Thread Mat Ellis
Why do these behave differently in Ripple? # Leaves key field blank property :key, Integer, :presence => true, :default => 1234 # Populates key2 field with 1234 property :key2, Integer, :presence => true, :default => 1234 We'd like to use the key field as a standard (like the 'id' field is the