Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uninitialised Constant Iconv

Recently was advised to used the following code in order to avoid UTF-8 problems with input text into a database.

ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')
#valid_string = ic.iconv(untrusted_string + ' ')[0..-2]
row[4] = ic.iconv(row[4] + ' ')[0..-2]
row[5] = ic.iconv(row[5] + ' ')[0..-2]

In development this works perfectly, however, once pushed onto our server we get the problem "uninitialised constant iconv" when we try to run the rake file containing the above code.

Is there an easy way to fix this issue? Tried adding gem 'iconv' to the gem file and running bundle install but this produced loads of errors, so assuming this is not the correct way to fix it...

like image 302
Texas Avatar asked Sep 02 '11 07:09

Texas


1 Answers

Fixed it by adding require 'iconv' at the top of the rake file

like image 146
Texas Avatar answered Nov 16 '22 16:11

Texas