Generate serialized attribute in fixture

Is there anyway to generate a serialized attribute like this one
inside the fixture :

knowledge: “— \n- 1\n- 3\n- 5\n- 7\n”

I tried
knowledge: <%= [1, 3, 5, 7].to_yaml %>

doesn’t not work… so I do it using irb, then copy/paste…

thanks

erwin

Does YAML::dump([1,3,5,7]) work ? You will need to require ‘yaml’ for
it.

On 9 Sep 2008, at 11:10, Erwin wrote:

Is there anyway to generate a serialized attribute like this one
inside the fixture :

knowledge: “— \n- 1\n- 3\n- 5\n- 7\n”

I tried
knowledge: <%= [1, 3, 5, 7].to_yaml %>

The difference between these two is that the second is actually sticking

knowledge:—

  • 1
  • 3
  • 5
  • 7

In your fixture which is not what you want.

knowledge: <%= [1, 3, 5, 7].to_yaml.inspect %>

Looks like it might do what you want.

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