I have a Rails 3 application with a pretty standard multipart form that includes an image upload. However, it throws an error.
The form starts with:
<%= form_for(@object, :html => { :multipart => true }) do |f| %>
<div class="field">
<%= f.label :photo %>
<%= f.file_field :photo %>
</div>
<div class="actions">
<%= f.submit 'Submit Object' %>
</div>
<% end %>
Then, I have this in the object.rb model:
def photo=(file_data)
unless file_data.blank
@file_data = file_data
self.extension = file_data.original_filename.split('.').last.downcase
end
end
This throws the following error:
undefined method `blank’ for #ActionDispatch::Http::UploadedFile:0x37ecc78
Meanwhile, it also shows the image exists in the Request Parameters error page:
“photo”=>#ActionDispatch::Http::UploadedFile:0x37ecc78 @original_filename=”Image.jpg”,
Any help would be greatly appreciated!
The
blankmethod doesn’t exist. It’sblank?, with the question mark.Documentation