You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the console to debug what's going on, and from the stack trace it's clear that as soon as I create a belongs_to association, dynamoid tries to save it to the DB. Shouldn't that be done when the object is saved?
For example, code like this could be executed when creating a form to create a new plan belonging to an event, the Plan instance is created but not saved.
lisa:~/dev/clowdserv$ rails console
Loading development environment (Rails 4.0.0)
1.9.3p448 :001 > e = Event.create(:event_id => "a3850a40-2f6e-11e3-aa6e-0800200c9a66")
=> #<Event:0x007fce4caa30f8 @new_record=false, @attributes={:created_at=>Mon, 07 Oct 2013 10:41:11 -0700, :updated_at=>Mon, 07 Oct 2013 10:41:11 -0700, :event_id=>"a3850a40-2f6e-11e3-aa6e-0800200c9a66", :plans_ids=>nil, :title=>nil, :status=>nil, :user_id=>nil}, @associations={}, @changed_attributes={}, @validation_context=nil, @errors=#<ActiveModel::Errors:0x007fce4ca27250 @base=#<Event:0x007fce4caa30f8 ...>, @messages={}>, @previously_changed={"event_id"=>[nil, "a3850a40-2f6e-11e3-aa6e-0800200c9a66"]}>
1.9.3p448 :002 > p = Plan.new
=> #<Plan:0x007fce4955a6a8 @new_record=true, @attributes={:created_at=>nil, :updated_at=>nil, :plan_id=>nil, :event_ids=>nil, :title=>nil, :location_title=>nil, :location_address=>nil, :start=>nil, :end=>nil}, @associations={}>
1.9.3p448 :003 > p.event = e
AWS::DynamoDB::Errors::ValidationException: One or more parameter values were invalid: Missing the key event_id in the item
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/aws-sdk-1.19.0/lib/aws/core/client.rb:366:in `return_or_raise'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/aws-sdk-1.19.0/lib/aws/core/client.rb:467:in `client_request'
from (eval):3:in `put_item'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/aws-sdk-1.19.0/lib/aws/dynamo_db/item_collection.rb:186:in `create'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/adapter/aws_sdk.rb:196:in `put_item'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/adapter.rb:146:in `block (3 levels) in <module:Adapter>'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/adapter.rb:39:in `benchmark'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/adapter.rb:146:in `block (2 levels) in <module:Adapter>'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/adapter.rb:58:in `write'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/persistence.rb:284:in `block in persist'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:383:in `_run__2844610546378516575__save__callbacks'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/persistence.rb:266:in `persist'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/persistence.rb:163:in `block in save'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:383:in `_run__2844610546378516575__create__callbacks'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/persistence.rb:163:in `save'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/validations.rb:17:in `save'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/identity_map.rb:72:in `save'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/dirty.rb:13:in `block in save'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/dirty.rb:28:in `clear_changes'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/dirty.rb:13:in `save'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/fields.rb:113:in `update_attribute'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/associations/single_association.rb:18:in `delete'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/associations/single_association.rb:11:in `setter'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/associations.rb:98:in `block in association'
from (irb):3
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
from /Users/lisa/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'1.9.3p448 :004 >
The text was updated successfully, but these errors were encountered:
I'm using the console to debug what's going on, and from the stack trace it's clear that as soon as I create a belongs_to association, dynamoid tries to save it to the DB. Shouldn't that be done when the object is saved?
For example, code like this could be executed when creating a form to create a new plan belonging to an event, the Plan instance is created but not saved.
The text was updated successfully, but these errors were encountered: