YAML.load(some_string) doesn't return hash?

A small problem here. As per documentation on
http://corelib.rubyonrails.org/classes/YAML.html YAML.load(string)
should just return a hash. However on my windows machine it returns
something like this:

#<YAML::Syck::DomainType:0x36d5038
@domain=“yaml.org,2002”,
@type_id=“map:HashWithIndifferentAccess”,
@value=
{“key”=>“value”,
“key”=>“value”,
“key”=>“value”,
“key”=>“value”,
}>

Obviously, on windows machine I have to do something like
YAML.load(something).value[‘key’] to get something. On Linux box .value
method will fail as we only get a simple hash there.

Any idea what is goin on? A bug?

Can we see the YAML you’re trying to load?

Jason

Oleg Kh wrote:

A small problem here. As per documentation on
http://corelib.rubyonrails.org/classes/YAML.html YAML.load(string)
should just return a hash. However on my windows machine it returns
something like this:

#<YAML::Syck::DomainType:0x36d5038
@domain=“yaml.org,2002”,
@type_id=“map:HashWithIndifferentAccess”,
@value=
{“key”=>“value”,
“key”=>“value”,
“key”=>“value”,
“key”=>“value”,
}>

Obviously, on windows machine I have to do something like
YAML.load(something).value[‘key’] to get something. On Linux box .value
method will fail as we only get a simple hash there.

Any idea what is goin on? A bug?

Now, I am seeing this problem, too, but in serializing.

Specifically, I have a field that’s serialized in my model. This works
fine going back and forth to a hash in Locomotive in development. But,
in production on DreamHost, the deseralization ends up like this:

!ruby/object:YAML::Syck::DomainType
domain: yaml.org,2002
type_id: map:HashWithIndifferentAccess
value:
key1: “value1”
key2: “value2”

Thus, of course, I can’t use the hash methods. And Rails then generates
errors like “undefined method `include?’ for
#YAML::Syck::DomainType:0x407fb584

I’m using Rails 1.1.6, and so is DreamHost. Does anyone have any ideas
what’s going on?

-Paul

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs