Search code examples
ruby-on-railscsvtype-conversionrake-task

Rails Convert String to Text


I created a rake task which is reading data from a csv file. It is reading the rows as strings. I have a description column in the table I am populating which is of type text.

I am wondering how to convert the string from the csv file to text so that the column will accept the data.

Thank you very much. The help is greatly appreciated as ruby and rails are still very new to me.


Solution

  • No conversion is needed!

    Ruby does not see a difference between 'string' and 'text', only some databases do.

    Just set the attribute on your object to the value from the CSV file and save it.