Ripple one Association Troubles

Stephen Allred stephenallred at stevesmiscellany.com
Tue Feb 8 17:18:18 EST 2011


So it turns out it was the 
---
def id
  email
end
---
that is causing the issue. Without it the association works fine (I'm assuming it is overriding some default ripple method/interfering with the linking somehow) but devise doesn't like the model without it. I'll try to dig some more for a fix.

Cheers,
Steve

On 8 Feb 2011, at 8:28 PM, Sean Cribbs wrote:

> You might also try upgrading to 1.9.2p136 (I hope you're using rvm). I'm not convinced that's the problem, however.
> 
> Sean Cribbs <sean at basho.com>
> Developer Advocate
> Basho Technologies, Inc.
> http://basho.com/
> 
> On Feb 8, 2011, at 3:11 PM, Stephen Allred wrote:
> 
>> Sean
>> 
>> $ ruby -v 
>> ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.3]
>> 
>> I'll try cleaning out my riak store and then without the devise code give it a go.
>> 
>> Cheers,
>> Steve
>> 
>> On 8 Feb 2011, at 8:08PM, Sean Cribbs wrote:
>> 
>>> Stephen,
>>> 
>>> Without loading the devise-ripple stuff, I copied and pasted your model code into irb, and cannot reproduce the problem.
>>> 
>>> irb> user = User.create(:email => "sean at basho.com")
>>> => <User:sean at basho.com email="sean at basho.com" password=nil password_confirmation=nil created_at=2011-02-08 20:06:27 UTC updated_at=2011-02-08 20:06:27 UTC> 
>>> irb> journal_entry = JournalEntry.new(:short_title => "test", :title => "test", :entry => "test")
>>> => <JournalEntry:test short_title="test" title="test" entry="test" created_at=2011-02-08 15:06:56 -0500 updated_at=nil> 
>>> irb> journal_entry.user = user
>>> => <User:sean at basho.com email="sean at basho.com" password=nil password_confirmation=nil created_at=2011-02-08 20:06:27 UTC updated_at=2011-02-08 20:06:27 UTC> 
>>> irb> journal_entry.save
>>> => true 
>>> irb> journal_entry.reload
>>> => <JournalEntry:test short_title="test" title="test" entry="test" created_at=2011-02-08 20:06:56 UTC updated_at=2011-02-08 20:07:14 UTC> 
>>> irb> journal_entry.user
>>> => <User:sean at basho.com email="sean at basho.com" password=nil password_confirmation=nil created_at=2011-02-08 20:06:27 UTC updated_at=2011-02-08 20:06:27 UTC> 
>>> 
>>> Out of curiosity, what version of Ruby are you using?
>>> 
>>> Sean Cribbs <sean at basho.com>
>>> Developer Advocate
>>> Basho Technologies, Inc.
>>> http://basho.com/
>>> 
>>> On Feb 8, 2011, at 2:54 PM, Stephen Allred wrote:
>>> 
>>>> I've tried commenting out the devise stuff and added the properties that came from devise:
>>>> 
>>>> --- user.rb ---
>>>> require 'ripple'
>>>> #require 'digest'
>>>> 
>>>> class User
>>>> include Ripple::Document
>>>> 
>>>> #devise :registerable, :confirmable, :database_authenticatable, :recoverable, :validatable
>>>> 
>>>> property :email,                  String, :presence => true
>>>> property :password,               String
>>>> property :password_confirmation,  String
>>>> property :encrypted_password,     String
>>>> property :password_salt,          String
>>>> property :reset_password_token,   String
>>>> property :confirmation_token,     String
>>>> property :confirmed_at,           String
>>>> property :confirmation_sent_at,   String
>>>> timestamps!
>>>> 
>>>> key_on :email
>>>> 
>>>> def key
>>>> email
>>>> end
>>>> 
>>>> def id
>>>> email
>>>> end
>>>> end
>>>> ---
>>>> 
>>>> I'm still getting the same "(Object doesn't support #inspect)" when I call journal_entry.user (nil class).
>>>> 
>>>> Cheers,
>>>> Steve
>>>> 
>>>> 
>>>> On 8 Feb 2011, at 7:01 PM, Sean Cribbs wrote:
>>>> 
>>>>> I haven't played with ripple-devise. Try commenting those parts out first and see what happens.
>>>>> 
>>>>> Sean Cribbs <sean at basho.com>
>>>>> Developer Advocate
>>>>> Basho Technologies, Inc.
>>>>> http://basho.com/
>>>>> 
>>>>> On Feb 8, 2011, at 1:53 PM, Stephen Allred wrote:
>>>>> 
>>>>>> Sean,
>>>>>> 
>>>>>> Yeah, I fetched it in using User.first before trying to assign it.
>>>>>> 
>>>>>> Could this have something to do with using ripple-devise (the User document is a ripple-devise user)?
>>>>>> 
>>>>>> Thanks,
>>>>>> Steve
>>>>>> 
>>>>>> 
>>>>>> On 8 Feb 2011, at 6:47 PM, Sean Cribbs wrote:
>>>>>> 
>>>>>>> Stephen,
>>>>>>> 
>>>>>>> Was your User object saved before you added it the journal entry?
>>>>>>> 
>>>>>>> Sean Cribbs <sean at basho.com>
>>>>>>> Developer Advocate
>>>>>>> Basho Technologies, Inc.
>>>>>>> http://basho.com/
>>>>>>> 
>>>>>>> On Feb 8, 2011, at 1:46 PM, Stephen Allred wrote:
>>>>>>> 
>>>>>>>> Sean,
>>>>>>>> 
>>>>>>>> $ puts journal_entry.robject.links.inspect
>>>>>>>> #<Set: {</riak/users/stephenallred%40stevesmiscellany.com>; riaktag="user", </riak/journal_entries>; riaktag="up"}>
>>>>>>>> => nil 
>>>>>>>> 
>>>>>>>> $ journal_entry
>>>>>>>> => <JournalEntry:test short_title="test" title="test" entry="test" created_at=2011-02-07 22:47:17 UTC updated_at=2011-02-08 18:08:47 UTC>
>>>>>>>> 
>>>>>>>> $ journal_entry.user
>>>>>>>> (Object doesn't support #inspect)
>>>>>>>> =>
>>>>>>>> 
>>>>>>>> $ journal_entry.user.inspect
>>>>>>>> NoMethodError: undefined method `key' for nil:NilClass
>>>>>>>> 	from /Users/stephenallred/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/whiny_nil.rb:48:in `method_missing'
>>>>>>>> 	from /Users/stephenallred/.rvm/gems/ruby-1.9.2-p0/gems/ripple-0.8.3/lib/ripple/document/finders.rb:122:in `block in instantiate'
>>>>>>>> 	from /Users/stephenallred/.rvm/gems/ruby-1.9.2-p0/gems/ripple-0.8.3/lib/ripple/document/finders.rb:121:in `tap'
>>>>>>>> 	from /Users/stephenallred/.rvm/gems/ruby-1.9.2-p0/gems/ripple-0.8.3/lib/ripple/document/finders.rb:121:in `instantiate'
>>>>>>>> 	from /Users/stephenallred/.rvm/gems/ruby-1.9.2-p0/gems/ripple-0.8.3/lib/ripple/associations/one_linked_proxy.rb:25:in `find_target'
>>>>>>>> 	from /Users/stephenallred/.rvm/gems/ruby-1.9.2-p0/gems/ripple-0.8.3/lib/ripple/associations/proxy.rb:113:in `load_target'
>>>>>>>> 	from /Users/stephenallred/.rvm/gems/ruby-1.9.2-p0/gems/ripple-0.8.3/lib/ripple/associations/proxy.rb:41:in `inspect'
>>>>>>>> 	from (irb):17
>>>>>>>> 	from /Users/stephenallred/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in `start'
>>>>>>>> 	from /Users/stephenallred/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in `start'
>>>>>>>> 	from /Users/stephenallred/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands.rb:23:in `<top (required)>'
>>>>>>>> 	from script/rails:6:in `require'
>>>>>>>> 	from script/rails:6:in `<main>'
>>>>>>>> 
>>>>>>>> Hopefully those are useful,
>>>>>>>> Thanks for the quick response!
>>>>>>>> Steve
>>>>>>>> 
>>>>>>>> On 8 Feb 2011, at 6:37 PM, Sean Cribbs wrote:
>>>>>>>> 
>>>>>>>>> Stephen,
>>>>>>>>> 
>>>>>>>>> Sounds like you've either found a bug.  When you have saved the journal entry in irb, what is the output of this command?
>>>>>>>>> 
>>>>>>>>> puts journal_entry.robject.links.inspect
>>>>>>>>> 
>>>>>>>>> Sean Cribbs <sean at basho.com>
>>>>>>>>> Developer Advocate
>>>>>>>>> Basho Technologies, Inc.
>>>>>>>>> http://basho.com/
>>>>>>>>> 
>>>>>>>>> On Feb 8, 2011, at 1:23 PM, Stephen Allred wrote:
>>>>>>>>> 
>>>>>>>>>> Hi all,
>>>>>>>>>> 
>>>>>>>>>> I'm having trouble setting up a one association in a ripple document. I'm trying to setup an association between a user and a journal entry, such that the journal has one user, that the user created.
>>>>>>>>>> 
>>>>>>>>>> My JournalEntry document:
>>>>>>>>>> 
>>>>>>>>>> --- journal_entry.rb ---
>>>>>>>>>> require 'ripple'
>>>>>>>>>> 
>>>>>>>>>> class JournalEntry
>>>>>>>>>> include Ripple::Document
>>>>>>>>>> 
>>>>>>>>>> property :short_title,  String, :presence => true
>>>>>>>>>> property :title,        String, :presence => true
>>>>>>>>>> property :entry,        String, :presence => true
>>>>>>>>>> 
>>>>>>>>>> timestamps!
>>>>>>>>>> 
>>>>>>>>>> one :user
>>>>>>>>>> 
>>>>>>>>>> key_on :short_title
>>>>>>>>>> end
>>>>>>>>>> ---
>>>>>>>>>> 
>>>>>>>>>> My User document:
>>>>>>>>>> 
>>>>>>>>>> --- user.rb ---
>>>>>>>>>> require 'ripple'
>>>>>>>>>> require 'digest'
>>>>>>>>>> 
>>>>>>>>>> class User
>>>>>>>>>> include Ripple::Document
>>>>>>>>>> 
>>>>>>>>>> devise :registerable, :confirmable, :database_authenticatable, :recoverable, :validatable
>>>>>>>>>> 
>>>>>>>>>> property :email,                  String, :presence => true
>>>>>>>>>> property :password,               String
>>>>>>>>>> property :password_confirmation,  String
>>>>>>>>>> timestamps!
>>>>>>>>>> 
>>>>>>>>>> key_on :email
>>>>>>>>>> 
>>>>>>>>>> def key
>>>>>>>>>> email
>>>>>>>>>> end
>>>>>>>>>> 
>>>>>>>>>> def id
>>>>>>>>>> email
>>>>>>>>>> end
>>>>>>>>>> end
>>>>>>>>>> ---
>>>>>>>>>> 
>>>>>>>>>> I've tried in the rails console to associate a user with journal_entry (journal_entry.user = user), save it and reload it. The resulting reloaded journal_entry does not have a user (calling journal_entry.user prints "(Object doesn't support #inspect)").
>>>>>>>>>> 
>>>>>>>>>> My journal entry in riak loaded via the browser looks like:
>>>>>>>>>> 
>>>>>>>>>> {"short_title":"test","title":"test","entry":"test","created_at":"Mon, 07 Feb 2011 22:47:17 -0000","updated_at":"Tue, 08 Feb 2011 18:08:47 -0000","_type":"JournalEntry"}
>>>>>>>>>> 
>>>>>>>>>> Does anyone know what I'm doing wrong?
>>>>>>>>>> Cheers!
>>>>>>>>>> Steve
>>>>>>>>>> _______________________________________________
>>>>>>>>>> riak-users mailing list
>>>>>>>>>> riak-users at lists.basho.com
>>>>>>>>>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 





More information about the riak-users mailing list