Reputation: 2174
So I have an object named plan_code
which is in the database as a string. However I'm trying to allow for multiple entries to be implemented. I have the user separated these entries by a comma.
I've worked on splitting the integers, but i've run into a problem in that after I split them and display them, they are surrounded by brackets as if they have become one large array.
In my model my code looks like
def bob
plan_code.split(",").map(&:to_i)
end
My results wind up as [123451, 52354, 12345]
I'm wondering what I can do to get rid of those brackets and just list the integers?
Upvotes: 0
Views: 2772
Reputation: 26758
If you're storing your values as a string such as "123, 123"
then there is no point in map &:to_i
.
You can use plan_code.split(",").join(", ")
or alternatively plan_code.gsub(",", ", ")
Upvotes: 2