utf 8 - Rails force input to encode in windows-1250 -
i'm making app on existing database in firebird charset windows-1250. , im getting lot of troubles because of encoding, cant change it.
my biggest error when im making form input object called notification this:
form |f| panel iconv.conv('windows-1250', 'utf-8', 'opis zgłoszenia:'), :class=> 'panel_dodaj_new' f.input :opis_zgloszenia, label:false end end
try save text in utf-8, want save in windows-1250.
how force :opis_zgloszenia
save in different charset utf-8?
i find way change encoding in controller.
in create method add:
@notification.opis_zgloszenia = iconv.conv('windows-1250', 'utf-8', @notification.opis_zgloszenia)
also need change update method:
if @notification.update(notification_params) @notification.opis_zgloszenia = iconv.conv('windows-1250', 'utf-8', @notification.opis_zgloszenia) if @notification.save redirect_to request.url end end
now works fine.
Comments
Post a Comment