Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7786225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:22:56+00:00 2026-06-01T20:22:56+00:00

I have a Rails (version 3.2.1) project and I recently switched from Ruby 1.8.7

  • 0

I have a Rails (version 3.2.1) project and I recently switched from Ruby 1.8.7 to Ruby 1.9.3. I added encoding comments in all .rb and .erb files but I have a problem with plain .js JavaScript assets. They contain comments in Polish saved with UTF-8 encoding. In most files it works fine – Ruby detects the encoding correctly – but in one file I have only a single UTF-8 character ś in a comment line. And now the Rails server fails with Encoding::CompatibilityError when displaying index page (which doesn’t even reference the JavaScript file).

I know it’s a problem with Ruby’s automatic encoding detection as it probably can’t detect encoding from single character outside ASCII range, but it’s very frustrating since it shouldn’t matter anyway – the file is only linked to as an asset.

My question is: how to enforce UTF-8 encoding in all .js assets?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:22:57+00:00Added an answer on June 1, 2026 at 8:22 pm

    try renaming it to js.erb and placing <%# encoding: utf-8 %> at the top

    found a hint here: Encoding issues in javascript files using rails asset pipeline

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started a Ruby on Rails 3 project to make an online version
I have a Rails 3.2.2 application using Ruby version 1.9.2. I have created basic
I'm trying to get a Ruby on Rails project started on Dreamhost, ruby version
I have been using the less-rails-bootstrap gem from https://github.com/metaskills/less-rails-bootstrap in my rails 3.1 project.
I'm a Git newbie. I recently moved a Rails project from Subversion to Git.
I have an existing Ruby on Rails project. How do I find out which
im using rails 2.3 and ruby 1.8.7, I have version .0.1.6 of crack vendored
I recently started working on a small personal project in Ruby on Rails, and
I have installed two different version of rails in same gem set. When I
I'm working with an older version of Rails and ActiveRecord that does not have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.