I'm using 'jbuilder' gem for creating Json. How can I create one Json that look like below
{ranking: {"1-3" => 2,"4-10" => 3, "11-20" => 5 }}
Description for hash
I've some keywords in my db each keyword having its own ranks in google search result. Above json key value pair representing number of keywords in my db that have ranks between 1 to 3, 4 to 10 and 11 to 20.
its easy to crate
{ranking: {"one_to_three" => 2,"four_to_ten" => 3, "eleven_to_twenty" => 5 }}
Using below code.
Jbuilder.new do |ranking|
ranking.one_to_three 2
ranking.four_to_ten 3
ranking.eleven_to_twenty 5
end
But I need to convert this as like
{ranking: {"1-3" => 2,"4-10" => 3, "11-20" => 5 }}
what are the changes i need to be made for above code to achieve this
Please help me