def upload
uploaded_io = params[:post][:image]
File.open(Rails.root.join('app/assets', 'uploads', uploaded_io.original_filename), 'w') do |file|
file.write(uploaded_io.read)
params[:post][:image] = uploaded_io.original_filename
end
end
这在我在 OS X 上的开发机器上运行良好,但是当运行相同的代码 eon heroku 时,我收到 500 错误,当我检查日志时,这似乎是导致它的原因
2012-09-21T16:57:08+00:00 app[web.1]: Encoding::UndefinedConversionError ("\xB6" from ASCII-8BIT to UTF-8):
2012-09-21T16:57:08+00:00 app[web.1]: app/controllers/posts_controller.rb:86:in `write'
2012-09-21T16:57:08+00:00 app[web.1]: app/controllers/posts_controller.rb:86:in `block in upload'
2012-09-21T16:57:08+00:00 app[web.1]: app/controllers/posts_controller.rb:85:in `open'
2012-09-21T16:57:08+00:00 app[web.1]: app/controllers/posts_controller.rb:85:in `upload'
2012-09-21T16:57:08+00:00 app[web.1]: app/controllers/posts_controller.rb:61:in `update'
我不知道该怎么做