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

  • Home
  • SEARCH
  • 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 6010763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:09:47+00:00 2026-05-23T02:09:47+00:00

I use rails 3 and paperclip plugin to attach files. I’ve got two models:

  • 0

I use rails 3 and paperclip plugin to attach files.

I’ve got two models:

  • Order;
  • OrderAttachment:
    • belongs_to :order;
    • has_attached_file :doc;

And I try to attach files to order via paperclip;

When I’m attaching files with English or numeric file name everything works great:

  SQL (0.0ms)  INSERT INTO "order_attachments" ("order_id", "created_at", "updated_at",  "doc_file_name", "doc_content_type", "doc_file_size", "doc_updated_at") VALUES (1, '2011-06-08 11:07:22.108523', '2011-06-08 11:07:22.108523', 'Example.txt', 'text/plain', 22, '2011-06-08 11:07:22.105523') RETURNING "id"
[paperclip] Saving attachments.
[paperclip] saving D:/my_project_path/public/system/docs/93/original/Example.txt
  SQL (1.0ms)  COMMIT
Completed 200 OK in 229ms (Views: 21.0ms | ActiveRecord: 7.0ms)

But when I’m attaching files with Russian file name error occurs:

SQL (1.0ms)  INSERT INTO "order_attachments" ("order_id", "created_at", "updated_at", "doc_file_name", "doc_content_type", "doc_file_size", "doc_updated_at") VALUES (1, '2011-06-08 11:26:43.040925', '2011-06-08 11:26:43.040925', 'Пример.txt', 'text/plain', 26, '2011-06-08 11:26:43.035924') RETURNING "id"
[paperclip] Saving attachments.
[paperclip] saving D:/my_project_path/public/system/docs/94/original/Пример.txt
  SQL (0.0ms)  ROLLBACK
Completed   in 161ms

Errno::ENOENT (No such file or directory - D:/my_project_path/public/system/docs/94/original/╨а╤Я╨б╨В╨а╤С╨а╤Ш╨а┬╡╨б╨В.txt):
  app/controllers/orders_controller.rb:138:in `attachment'

Paperclip saves file to D:/my_project_path/public/system/docs/94/original/Пример.txt (i can open it via explorer) but no record in database created. Maybe something wrong with encoding.

I use:

  • Windows 7 professional x64;
  • PostgreSQL 9.0 (UTF-8 database encoding);
  • Ruby 1.9.2;
  • Ruby on Rails 3.0.7;
  • Paperclip 2.3.11;

Thanks for any help.

  • 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-23T02:09:48+00:00Added an answer on May 23, 2026 at 2:09 am

    As i said paperclip saves attached file and rails creates valid request, but something inside paperclip source goes frong under Windows.

    Errno::ENOENT exception was caught in C:\Ruby192\lib\ruby\gems\1.9.1\gems\paperclip-2.3.11\lib\paperclip\storage\filesystem.rb source file in line 42

    def flush_writes #:nodoc:
      @queued_for_write.each do |style_name, file|
        file.close
        FileUtils.mkdir_p(File.dirname(path(style_name)))
        log("saving #{path(style_name)}")
        FileUtils.mv(file.path, path(style_name))
        FileUtils.chmod(0644, path(style_name))
      end
      @queued_for_write = {}
    end
    

    I changed this function to:

    def flush_writes #:nodoc:
      @queued_for_write.each do |style_name, file|
        file.close
        FileUtils.mkdir_p(File.dirname(path(style_name)))
        log("saving #{path(style_name)}")
        FileUtils.mv(file.path, path(style_name))
        begin
          FileUtils.chmod(0644, path(style_name))
        rescue Errno::ENOENT
          log("Errno::ENOENT caught on #{ENV['OS']}")
        end
      end
      @queued_for_write = {}
    end
    

    This solution works for me. Now sever log output is:

      SQL (1.0ms)  INSERT INTO "order_attachments" ("order_id", "created_at", "updated_at", "doc_file_name", "doc_content_type", "doc_file_size", "doc_updated_at") VALUES (14, '2011-06-08 18:44:25.853559', '2011-06-08 18:44:25.853559', 'Пример.doc', 'application/msword', 292352, '2011-06-08 18:44:25.727552') RETURNING "id"
    [paperclip] Saving attachments.
    [paperclip] saving D:/my_project_path/public/system/docs/199/original/Пример.doc
    [paperclip] Errno::ENOENT caught on Windows_NT    --> !!! here it is - our exception !!!
      SQL (3.0ms)  COMMIT
    Completed 200 OK in 287ms (Views: 13.0ms | ActiveRecord: 15.0ms)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use the paperclip plugin in my rails app to upload
In models and controllers, we often use Rails macros like before_validation , skip_before_filter on
I'm building an app to store files on my s3 account. I use Rails
I am trying to attach files in my RoR app. I am using Rails
I want to use paperclip plugin to upload the file but the problem is
using rails with Paperclip, I can use the following to get the filename during
I'm trying to use paperclip in rails and when I'm doing the bundle install
I use Paperclip 2.3.11 in my Rails 3 application, and I create thumbnails using:
I'm trying to use paperclip with rails 3.1 but I keep getting this routing
I'm trying to use the paperclip gem to upload photos in my rails project.

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.