in Education by
I moved a web app that was using 1.8.7 to 1.9.2 and now I keep getting incompatible character encodings: ASCII-8BIT and UTF-8 I have the database encoding to UTF-8 and I have also 'config.encoding = "utf-8"'. I saw some ideas as possible workarounds and I added Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 But it didn't work either. One specific chunk of code where I am getting this error is %ul.address - @user.address.split(',').each do |line| %li= line.titleize I'm using HAML, I checked line.titleize, and the encoding is UTF-8. Seems that the template is being rendered with ASCII-8BIT and it gets screwed each time that I try to render characteres like 'ñ' I'm working with Rails 3.0.5. I have read the post by James Edward Gray, but I still can figure it out what is going on ;(. I'd really appreciate any kind of help :D. I also tried: "string".force_encoding("UTF-8") And # encoding: utf-8 Without any luck. Fixed See comments. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I just ran into something similar ... and found the fix hidden in the comments to this question, but think it is worth highlighting explicitly: cookies are ASCII-8BIT but rails 3 templates are utf-8 by default. This means using a raw cookie value in a view may raise Encoding::CompatibilityError (if the user has an incompatible in the cookie value) The fix (as noted by Adolfo Builes) is to coerce your cookie values to UTF-8, as in: cookies["location"].force_encoding('UTF-8')

Related questions

0 votes
    I'm trying to import an XML file via a web page in a Ruby on Rails application, the code ruby ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
0 votes
    Which of the following is not a valid encoding scheme for character?a. ASCII b. ISCII c. Unicode and. ASCII Select the correct answer from above options...
asked Dec 25, 2021 in Education by JackTerrance
0 votes
    While running the server, i am getting the error incompatible library version.Already Nokogiri is installed in ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I'm upgrading an application from Rails 3.0 to 3.1 and found the following error showing up in my ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 21, 2022 in Education by JackTerrance
0 votes
    I made a basic rails app with a simple pages controller with an index function and when I load the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    The digits 1,2,3,4,5,6,7,8 and 9 are written in random order to form a nine digit number. The probability that this ... 2 9 2 D. 7 9 7 Select the correct answer from above options...
asked Nov 15, 2021 in Education by JackTerrance
0 votes
    Can you arrange 9 numerals - 1, 2, 3, 4, 5, 6, 7, 8 and 9 [using each numeral just once] above and below a division line, to create a fraction equaling to 1/3 [one third]?...
asked Feb 13, 2021 in Education by JackTerrance
0 votes
    _____________ will produce a sequential vector c( (1,2,3,4,5,6,7,8,9)). (a) Seq(9) (b) Seq ... Functions and Debugging of R Programming Select the correct answer from above options...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    >>> list(range(0, -9,-1)) will print [-1, -2, -3, -4,-5, -6, -7, -8) [0,-1, -2, -3, -4,-5, -6, -7, -8 ... [0,-1, -2, -3, -4,-5, -6, -7] Select the correct answer from above options...
asked Dec 28, 2021 in Education by JackTerrance
0 votes
    A hash table can store a maximum of 10 records, currently there are records in location 1, 3,4,7, ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    I currentyl have no clue on how to sort an array which contains UTF-8 encoded strings in PHP. The ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    Find a 10-digit number, where the first figure defines the count of zeros in this number, the second figure the ... character expresses the count of the numeral 9 in this number....
asked Feb 13, 2021 in Education by JackTerrance
0 votes
    I would like to change the user sign-in behaviour of devise in a way to redirect a user to a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
...