I read the similar questions, but it was not my case I think.
My view:
= form_for [:test, @new], :remote => true do |f|
= f.label :title, 'title'
= f.text_field :title, :class => :span6
= label :news, :image_preview, 'Изображение'
= file_field :news, :image_preview, :class => 'btn'
My controller:
def create
uploaded_io = params[:news][:image_preview]
File.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'w') do |file|
file.write(uploaded_io.read)
end
end
Uploading file I get this error:
undefined method `original_filename' for "download.png":String