I am getting a stringify_keys error.
Currently I am calling the following method which works perfectly:
def attributes
{
city: @content[1..20].strip,
streetname: @content[21..40].strip,
house_number: @content[41..46].strip.to_i
}
end
Now that I am refactoring my code, I need to build the hash from the ground up where the keys and values are populating the hash based on certain conditions (conditions are not written yet).
def attributes
test = {}
test["city"] = @content[1..20].strip
test["streetname"] = @content[21..40].strip
test["house_number"] = @content[41..46].strip.to_i
end
Now I am getting the stringify_keys error. I checked the docs for clues on how to build a hash but there isn't anything that could help me.
Where is the problem? If you need more code, please ask.
test["city"]usetest[:city].SymboltoString. Also, your new method returns the value of@content[41..46].strip.to_i(the last value of the method), whereas your old method returns the entireHash. That could cause issues as well. Since yourattributesreturns aFixnum, you might getNoMethodError: undefined method 'stringify_keys' for Fixnumbecause of it. Fix byreturn testor justteston the last line of your method.