Paperclip and tempfile with Rails

Posted by Eric Koslow on Stack Overflow See other posts from Stack Overflow or by Eric Koslow
Published on 2010-03-20T13:47:45Z Indexed on 2010/03/20 13:51 UTC
Read the original article Hit count: 803

I'm trying to write a rails application where users can upload images, but Paperclip doesn't seem to be working for me.

I've gone through all the basic steps (added has_attached_file, the migration, making the form multipart) but I keep getting the same error whenever I try uploading an image:

can't convert nil into Integer

Looking at the top of the stack

...rails3/lib/paperclip/processor.rb:46:in `sprintf'

...rails3/lib/paperclip/processor.rb:46:in `make_tmpname'

.../ruby-1.9.2-head/lib/ruby/1.9.1/tmpdir.rb:154:in `create'

.../ruby-1.9.2-head/lib/ruby/1.9.1/tempfile.rb:134:in `initialize'

It seems the problem is in the tempfile.

My code:

_form.rb

<%= form_for @high_school, :html => {:multipart => true} do |f| %>
  <%= f.error_messages %>
  ...
  <div class="field">
    <%= f.file_field :photo %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

model/high_school.rb

...
validates_length_of :password, :minimum => 4, :allow_blank => true
has_attached_file :photo
has_many :students
...

Is this a known problem? I basically followed the instructions from the github to the letter.

My environment: Rails3 and Ruby 1.9.2dev

Thank you!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby