No such file or directory, file_column problem

Hi,All:
   I met a strange problem with file_column. My application worked well
before I changed my Model, I only changed the size of picture. but cause
the following problems:

No such file or directory -
D:/WORK_HOME/rails-projects/work/public/uploads/teacher/image/tmp/1222073389.593000.1264/Clayton04.JPG
or
D:/WORK_HOME/rails-projects/work/public/uploads/teacher/image/tmp/1222073389.593000.1264/Clayton04.jpg

D:/ruby/lib/ruby/1.8/fileutils.rb:505:in `rename'
D:/ruby/lib/ruby/1.8/fileutils.rb:505:in `mv'
D:/ruby/lib/ruby/1.8/fileutils.rb:1395:in `fu_each_src_dest'
D:/ruby/lib/ruby/1.8/fileutils.rb:1411:in `fu_each_src_dest0'
D:/ruby/lib/ruby/1.8/fileutils.rb:1393:in `fu_each_src_dest'
D:/ruby/lib/ruby/1.8/fileutils.rb:494:in `mv'
vendor/plugins/file_column/lib/file_column.rb:210:in `store_upload'
vendor/plugins/file_column/lib/file_column.rb:339:in `upload'
vendor/plugins/file_column/lib/file_column.rb:54:in `assign'
vendor/plugins/file_column/lib/file_column.rb:584:in `image='
D:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2361:in
`send'
D:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2361:in
`attributes='
D:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2360:in
`each'
D:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2360:in
`attributes='
D:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2261:in
`update_attributes'
app/controllers/admin/teachers_controller.rb:46:in `update'

thanks for any help.

Wu Chang wrote:

vendor/plugins/file_column/lib/file_column.rb:210:in `store_upload'

.........

I have found the reason for this problem.the codes ignored the case of
suffix in "file_column.rb:210:in `store_upload'" .

so, if uploading a file like 'aaa.JPG',the bug will be appeared.

Hope it will be helpful for somebody else.

Hmm.. I got the same error almost. Just that it shows just a directory
not the file that was downloaded into the directory.

Below is the error-printout when using the simplest rails-application to
test file_column that you can do.

I'm totally new to ruby and rails so...just take it easy with me :wink:

bild.rb <<<<<<<<<<<

class Bild < ActiveRecord::Base
  file_column :image, :magick => { :versions => {"thumb" => "90x90",
"medium" => "640X480"}}
end

new.html.erb <<<<<<<<<<<<<

<h1>New bild</h1>

<%= error_messages_for :bild %>

<% form_for(@bild, :html => { :multipart => true }) do |f| %>
  <p>
    <b>Comment</b><br />
    <%= f.text_field :comment %>
  </p>

  <p>
    <b>Image</b><br />
<b><%= file_column_field "bild", "image" %></b>
</p>

  <p>
    <%= f.submit "Create" %>
  </p>
<% end %>

<%= link_to 'Back', bilds_path %>

show.html.erb <<<<<<<<<<

<p>
  <b>Comment:</b>
  <%=h @bild.comment %>
</p>

<p>
  <b>Image:</b>
<%= image_tag url_for_file_column("bild", "image") %>
</p>

<%= link_to 'Edit', edit_bild_path(@bild) %> |
<%= link_to 'Back', bilds_path %>

Eeeeaaahhhh...what happends? Why all these lines?? I just made a simple
cut and paste and it was just a fraction of all these lines...?

Well sorry but I don't know if you can edit your own posts..?

I changed the line 210 in file_column.rb to following:
        FileUtils.mv(local_file_path, new_local_file_path) unless
new_local_file_path.upcase == local_file_path.upcase

Wu Chang wrote:

I changed the line 210 in file_column.rb to following:
        FileUtils.mv(local_file_path, new_local_file_path) unless
new_local_file_path.upcase == local_file_path.upcase

I've tried that but no success.
I tried to debug and found that it want to move the temporary directory
to a new that not exist and then it bailouts. The image column is never
updated so it is allways nil.

ex:
mv app/public/object/image/tmp/unique_dir_name/ to
app/public/object/image/development/id/

The destination does not exist. I don't know what rails do in the
background but normally you can't move a dir to a dir that do not exist.
Maybe it tries to rename it but I'm sure there are restrictions also
there...?

I have worked with this for a couple of weeks now.. I never had such a
problem in my whole programming life (about 30 years).

I'm sure it's a bug - How can I make it work

Lars-göran Andersson wrote:

Wu Chang wrote:

I changed the line 210 in file_column.rb to following:
        FileUtils.mv(local_file_path, new_local_file_path) unless
new_local_file_path.upcase == local_file_path.upcase

I've tried that but no success.
I tried to debug and found that it want to move the temporary directory
to a new that not exist and then it bailouts. The image column is never
updated so it is allways nil.

ex:
mv app/public/object/image/tmp/unique_dir_name/ to
app/public/object/image/development/id/

The destination does not exist. I don't know what rails do in the
background but normally you can't move a dir to a dir that do not exist.
Maybe it tries to rename it but I'm sure there are restrictions also
there...?

I have worked with this for a couple of weeks now.. I never had such a
problem in my whole programming life (about 30 years).

I'm sure it's a bug - How can I make it work

I guess the places of bugs:

   1.the uploaded file name will be sanitized before move to
"app/public/object/image/development/id/", so, you can print the file
name when debuging the file_column, try to find the bugs.
   2.the destination's permission.
   3.get the latest version of file_column.

Good luck.