我读过类似的问题,但我认为不是我的情况。
我的观点:
= 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'
我的控制器:
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
上传文件我收到此错误:
undefined method `original_filename' for "download.png":String