What is the best way to turn the next Ruby String into an array (I am using ruby 1.9.2 / Rails 3.0.11)
Rails Console:
>Item.first.ingredients => "[\"Bread, whole wheat, 100%, slice\", \"Egg Substitute\", \"new, Eggs, scrambled\"]" >Item.first.ingredients.class.name => "String" >Item.first.ingredients.length 77
Desired Result:
>Item.first.ingredients_a ["Bread, whole wheat, 100%, slice", "Egg Substitute", "new, Eggs, scrambled"] >Item.first.ingredients_a.class.name => "Array >Item.first.ingredients_a.length => 3
If I do this, for example:
>Array(Choice.first.ingredients)
I get this:
=> ["[\"Bread, whole wheat, 100%, slice\", \"Egg Substitute\", \"new, Eggs, scrambled\", \"Oats, rolled, old fashioned\", \"Syrup, pancake\", \"Water, tap\", \"Oil, olive blend\", \"Spice, cinnamon, ground\", \"Seeds, sunflower, kernels, dried\", \"Flavor, vanilla extract\", \"Honey, strained/extracted\", \"Raisins, seedless\", \"Cranberries, dried, swtnd\", \"Spice, ginger, ground\", \"Flour, whole wheat\"]"]
I am sure there must be some obvious way to solve this problem.
For clarity, this will be edited in the textarea field of the form, so it should be made as safe as possible.