开发者

rails3, confused about using params[:filename].tempfile.path vs params[:filename][:tempfile].path

On a Rails 3 app hosted at Heroku, where a multipart file is POSTed to my app, I'm trying to use some sample code that says :

File.open(params['filename'][:tempfile].path)

however,开发者_StackOverflow社区 my logs show the error NoMethodErr no such method as tempfile.

I also tried

File.open(params[:filename].tempfile.path)

got the same error.

I added require 'tempfile' to my Controller, made no difference.


When a file is posted to your application, the object in the params should already be a Tempfile so calling [:tempfile] or .tempfile should not be necessary. Try something like this:

File.open params[:filename].path
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜