Get Ruby Object (that you need to convert to hash) into one variable.
=> user = User.first
#<User id: 1, name: “Test", email: “[email protected]", updated_at: "2019-01-23 06:03:20”>
Below method will convert your Ruby Object into hash.
=> user.as_json
{"id"=>1, "name"=>"Test", "email"=>"[email protected]", "updated_at"=>Wed, 23 Jan 2019 06:03:20 UTC +00:00}
Find below link for details about Hash:
https://ruby-doc.org/core-2.2.0/Hash.html
Hello, I am Denail Soovy. I am a developer of different technology. I am passionate about teaching and Daily teaching many students. I want to share knowledge with all of the developers or other people who need it.
I will try to teach every student with my easy and updated blogs.