Actions
Bug #4571
open"Domain (..) expected, got ActiveSupport::HashWithIndifferentAccess(..)" when setting associations with wrapped object
Status:
New
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Description
When using the GET JSON style of setting object associations from #3693, this throws an exception when you wrap the entire object. For example:
PUT /api/v2/subnets/1 {"domains":[{"name":"fm.example.net"}]}
Updates successfully,
PUT /api/v2/subnets/1 {"subnet":{"domains":[{"name":"fm.example.net"}]}}
returns:
{ "error": {"message":"Domain(#69867421437000) expected, got ActiveSupport::HashWithIndifferentAccess(#18235220)"} }
Stack trace:
Domain(#69867421437000) expected, got ActiveSupport::HashWithIndifferentAccess(#18235220) (ActiveRecord::AssociationTypeMismatch) /home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.17/lib/active_record/associations/association.rb:210:in `raise_on_type_mismatch' /home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.17/lib/active_record/associations/collection_association.rb:310:in `block in replace' /home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.17/lib/active_record/associations/collection_association.rb:310:in `each' /home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.17/lib/active_record/associations/collection_association.rb:310:in `replace' /home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.17/lib/active_record/associations/collection_association.rb:41:in `writer' /home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.17/lib/active_record/associations/builder/association.rb:51:in `block in define_writers' /home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.17/lib/active_record/attribute_assignment.rb:85:in `block in assign_attributes' /home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.17/lib/active_record/attribute_assignment.rb:78:in `each' /home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.17/lib/active_record/attribute_assignment.rb:78:in `assign_attributes' /home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.17/lib/active_record/persistence.rb:216:in `block in update_attributes' /home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.17/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status' /home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction' /home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.17/lib/active_record/transactions.rb:208:in `transaction' /home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.17/lib/active_record/transactions.rb:311:in `with_transaction_returning_status' /home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.17/lib/active_record/persistence.rb:215:in `update_attributes' /home/dcleal/code/foreman/foreman/app/controllers/api/v2/subnets_controller.rb:60:in `update'
Updated by Dominic Cleal over 10 years ago
- Related to Feature #3693: API v2 - accept GET json format of object in PUT/POST requests to add/remove has_many associations added
Updated by Dominic Cleal over 10 years ago
- Related to Bug #4567: Unable to reliably unset all object associations added
Actions