I want access each of 1_1
1_2
1_3
from my rails views ,
Now how i can define each of this in my Odd
class to access them ?
I get this error no implicit conversion of String into Integer
on this line Odd.new(args.fetch("1_1", {}))
Json responce :
{
"success": 1,
"results": {
"1_1": [
{
"id": "1976855",
"home_od": "501.000",
"draw_od": "17.000",
"away_od": "1.025",
"ss": "0:1",
"time_str": "91",
"add_time": "1480296195"
}
],
"1_2": [
{
"id": "1976855",
"home_od": "501.000",
"draw_od": "17.000",
"away_od": "1.025",
"ss": "0:1",
"time_str": "91",
"add_time": "1480296195"
}
],
"1_3": [
{
"id": "1976855",
"home_od": "501.000",
"draw_od": "17.000",
"away_od": "1.025",
"ss": "0:1",
"time_str": "91",
"add_time": "1480296195"
}
]
}
}
odd model
module Bapi
class Odd < Base
attr_accessor :event_id,
:full_time
CACHE_DEFAULTS = { expires_in: 7.day, force: false }
def self.find(query = {})
cache = CACHE_DEFAULTS
response = Request.where("/v1/event/odds",CACHE_DEFAULTS, query)
inplaies = response.fetch('results',[]).map { |odd| Odd.new(odd) }
inplaies
end
def initialize(args = {})
super(args)
self.full_time = parse_1x2(args)
end
def parse_1x2(args = {})
Odd.new(args.fetch("1_1", {}))
end
end
end