"cannot convert character to integer" strange error
This is the hash I'm working on
a = {
#...
:fares => {
:itinerary_fare => {
:segment_names=>"C",
:free_seats => "6",
:fare_for_one_passenger => {
:free_seats=>"0",
:@currency => "TL",
:@non_refundable => "false",
:@price => "439.0",
:@service_fee => "25.0",
:@tax => "33.0",
:@type => "Y"
},
:@currency => "TL",
:@non_refundable => "false",
:@price => "439.0",
:@service_fee => "25.0",
:@tax => "33.0",
:@type => "C"
},
:@currency => "TL",
:@tax => "33.0"
},
#..
}
also here is another example http://pastebin.com/ukTu8GaG .
The code that gives me headhaches,
a[:fares][:itinerary_fare].each do |f|
puts f[:@price]
end
If I write this to the console, it gives me the error "Unable to convert character to integer." But if I write, a[:fares][:itinerary_fare][:@price]it works very well.
The weirdest part: if I write code to a haml file
%tbody
-@flights.each do |a|
%tr.flight
%td
-a[:fares][:itinerary_fare].each do |f|
-puts f[:@price] #Weird stuff happens here
.prices
%input{:type=>"radio",:name=>"selectedfight",:value=>"#{a[:id]}"}
= f[:@price]
%br
It works, it prints prices for my console, but it fails in SAME LINE.
can't convert Symbol into Integer file: flights.haml location: [] line: 18
This is the most troubling mistake I have ever seen, thanks for any help.
In most cases, more than 1 :itinerary_fare, I have to iterate.
My data can be displayed as http://postimage.org/image/6nnbk9l35/
a[:fares][:itinerary_fare] Hash. Hash#each - .
, f , . [:@price, "439.0"] .
, (:@price) . .
a[:fares][:itinerary_fare][:@price] -, , .
, ? .
, a[:fares][:itinerary_fare].
a[:fares][:itinerary_fare].each do |f|
puts f
end
, :
a[:fares][:itinerary_fare][:@price]
: itinerary_fare, , : . , ( ):
a = {:id=>"1",
:fares=>{
:itinerary_fares=>[{:@price=>"439"}, {:@price=>"1000"}]
}
}
:
a[:fares][:itinerary_fares].each do |f|
puts f[:@price]
end