Project

General

Profile

Actions

Bug #4568

closed

undefined method `keys' for "5":String when setting associations incorrectly

Added by Dominic Cleal about 10 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

PUT /api/v2/subnets/1
{"domains":["5"]}

returns this error:

{"error": {"message":"undefined method `keys' for \"5\":String"}}

Which is correct, as the correct format is:

{"domains":[{"id":"5"}]}

But it's not a user-friendly error message. Better yet would be if it could simply accept this format with IDs or names.

Stack trace:

undefined method `keys' for "5":String (NoMethodError)
/home/dcleal/code/foreman/foreman/app/controllers/api/v2/base_controller.rb:64:in `block (2 levels) in setup_has_many_params'
/home/dcleal/code/foreman/foreman/app/controllers/api/v2/base_controller.rb:64:in `each'
/home/dcleal/code/foreman/foreman/app/controllers/api/v2/base_controller.rb:64:in `all?'
/home/dcleal/code/foreman/foreman/app/controllers/api/v2/base_controller.rb:64:in `block in setup_has_many_params'
/home/dcleal/code/foreman/foreman/app/controllers/api/v2/base_controller.rb:60:in `each'
/home/dcleal/code/foreman/foreman/app/controllers/api/v2/base_controller.rb:60:in `setup_has_many_params'

Actions #1

Updated by Dominic Cleal about 10 years ago

  • Description updated (diff)
Actions #2

Updated by Leos Stejskal about 3 years ago

  • Status changed from New to Closed

I'm closing the issue,
It has been here for some time and I wasn't able to reproduce it on the latest version.
If you think that the issue is still relevant feel free to reopen it.

Actions

Also available in: Atom PDF