0
votes

i am using rails 4.1 with mysql.

In the database table for a column i have a blob datatype wherein i am saving news paper articles, but while fetching all in index action i am getting below error.

Encoding::UndefinedConversionError ("\xE2" from ASCII-8BIT to UTF-8):

i tried many solutions on the net , but not able to resolve the issue.

* before_save { self.article = article.encode('utf-8', :invalid => :replace, :undef => :replace, :replace => '_')}* etc..

your help is highly appreciated.. thanks

1
Why use a blob column if the data is text ? - Frederick Cheung
I want to store large amount of data like 5000 words, which i was not able to do with text datatype. - Mayur Randive
Hey Frederick thanks for questioning " why ? " :) - Mayur Randive

1 Answers

1
votes

FYI .. it is resolved i changed Data type from BLOB to TEXT and it worked.

BLOB values are treated as binary strings (byte strings). They have no character set, and sorting and comparison are based on the numeric values of the bytes in column values. TEXT values are treated as nonbinary strings (character strings). They have a character set, and values are sorted and compared based on the collation of the character set.

The BLOB and TEXT Types