Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7929717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:10:50+00:00 2026-06-03T20:10:50+00:00

The is the hash I am working on, a = { #… :fares =>

  • 0

The is the hash I am 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 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 into console, it gives me “can’t convert Symbol into Integer” error. But if I write, a[:fares][:itinerary_fare][:@price] it works pretty fine.

The weirdest part is, if I write the 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 the prices to my console, yet it fails at the SAME LINE.

can't convert Symbol into Integer file: flights.haml location: [] line: 18

This is the most disturbing error I have ever seen, thanks for any help.

Most of the time there are more than 1 :itinerary_fare, I have to iterate.

My data can be shown as http://postimage.org/image/6nnbk9l35/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:10:52+00:00Added an answer on June 3, 2026 at 8:10 pm

    a[:fares][:itinerary_fare] is a Hash. Hash#each yields key-value-pair arrays to the block.

    So, f takes e.g. the array [:@price, "439.0"] in the block.

    Hence you are using a symbol (:@price) as an array index. An integer is expected.

    In a[:fares][:itinerary_fare][:@price] you are giving it as hash key which works of course.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone show me a working example of how to generate a SHA hash
I'm working on a multimethod that needs to update a hash for a bunch
I'm working on a project where I need to use some hash function to
Perl newbie here...I had help with this working perl script with some HASH code
I am working with the Spreadsheet::ParseExcel module. I want to create a hash of
I'm currently working with a hash function as such: unsigned long hashFunc(const char *str,
I'm working on implanting Facebook in my app. Now I didn't put the Hash
I am working on a script that creates several fairly complex nested hash datastructures
I'm working on something similiar to GlotPress. I have two tables strings hash (primary
Part of my software build process includes getting the hash of the working directory

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.