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 6570849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:48:28+00:00 2026-05-25T14:48:28+00:00

I am uploading an image with a file name containing an umlaut via dragonfly

  • 0

I am uploading an image with a file name containing an umlaut via dragonfly in a Rails 3 app on Heroku. Then I’m trying to display the image using

image_tag @model.image.url, …

In development everything works just fine, but in production I’m getting:

incompatible character encodings: UTF-8 and ASCII-8BIT
.bundle/gems/ruby/1.9.1/gems/actionpack-3.0.7/lib/action_view/helpers/tag_helper.rb:129:in `*'

After reading a bit I’ve added

Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8

in environment.rb but the problem remains.

What is the proper way to go about this? Do I have to fix the file name when uploading? I was under the impression this should work just fine in Rails 3?

  • 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-05-25T14:48:29+00:00Added an answer on May 25, 2026 at 2:48 pm

    Well, you could try something like url.force_encoding('utf8')

    You could also simply sanitize the url in the model before saving it to the database – that’s what I did. And, yes, I sometimes stumble over this in the weirdest places, too.

    This is what my model looked like:

    # encoding: UTF-8
    class Page < ActiveRecord::Base
      before_save :sanitize_title
    
      private
      def sanitize_title
        self.title = self.title.force_encoding('UTF-8').downcase.gsub(/[ \-äöüß]/, ' ' => '_', '-' => '_', 'ä' => 'ae', 'ö' => 'oe', 'ü' => 'ue', 'ß' => 'ss').gsub(/[^a-z_]/,'')
      end
    end
    

    This will replace the German umlaute with their ASCII counterparts, convert spaces to underscores and drop everything else.
    The first line # encoding: UTF-8 is important or ruby will complain of non-ASCII characters in the model.rb file…

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

Sidebar

Related Questions

I am handling a uploading image file using PHP, then using ImageMagick to create
So i'm uploading any image file via my great upload form and it uploads
I am uploading image using filedrop.js. Code in application.js file looks like this:- $(.droparea).each(function(event){
I am uploading an image to a folder name upload. Then I am changing
I'm uploading an image file via AJAX ajaxFileUpload plugin which uses iframe to submit
I am having problem uploading image to mongodb using rails and carrierwave. This is
I trying to display the name of the file after the user has uploaded
I am uploading image to server using base64 its working fine if image is
I am uploading in image via a form and I want to, in addition
How should I handle image uploading using PHP? How should I handle the chmod

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.