'How to pass parameter as hash in Rails api with GET?
I try to pass params as a hash in url with postman like this
http://localhost:3000/api/v1/bill?album=3&song=4&song=7&album=6
I use this code to get param
def param_hash
params.permit(:album, :song)
end
and print this value param_hash.to_h
This is a value i want {"album"=3, "song"=>4, "album"=>6, "song"=>7} But in reality that's what i got {"album"=>6, "song"=>7} , just have only 1 hash in last.
Is there anyway to take all hash value in url?
Solution 1:[1]
http://localhost:3000/api/v1/bill?data={album: 3,song: 4,song: 7,album: 6 }
Use the above logic and permit the 'data' object.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | kishore cheruku |
