undefined方法`original_filename'代表“download.png”:String

时间:2013-06-28 08:44:40

标签: ruby-on-rails file methods upload undefined

我读过类似的问题,但我认为不是我的情况。

我的观点:

    = 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

0 个答案:

没有答案