hm. If I unserstand you right.
your result seems like this:
=> "\n \t\t\t\t\t\t\t\n\t\t\t\t\t\t\tSamsung\n \t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tNokia\n \t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tApple\n \t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tHTC\n \t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tSony\n \t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tBlackberry"
Try THIS:
?> >> name.gsub(/\s+/, " ")
get's this:
=> "Samsung Nokia Apple HTC Sony Blackberry"
Then you can take each word and put it in an array:
"Samsung Nokia Apple HTC Sony Blackberry".split(/\W+/)
Which gets this:
["Samsung", "Nokia", "Apple", "HTC", "Sony", "Blackberry"]
then you can do this:
["Samsung", "Nokia", "Apple", "HTC", "Sony", "Blackberry"].each do |manufacturer_name|
Category.create(name: manufacturer_name)
end
Then you have six Categories in your db
Category.count # returns 6