Every time I think I'm "getting" RoR something trivial kicks my
butt. All I am trying to do is upload text files for processing.
I’ve stripped everything out of my code in order to troubleshoot this
and I’ve hit a wall :
def savefile @thefile = params[:scanfile][:thefile]
render_text @thefile.content_type
end
The problem is that what I get from the params hash is always just a
plain string. It is not a file object with .read or .content_type
methods. I get this error in firefox:
undefined method `conent_type’ for “scandata.txt”:String
Can anyone spot what I have done wrong? I swear that I’ve used this
same simple approach successfully in other apps.
The problem is that what I get from the params hash is
always just a plain string. It is not a file object with
.read or .content_type methods. I get this error in firefox:
undefined method `conent_type’ for “scandata.txt”:String
Thanks Bill, that is much more knowledge than I had 2 hours ago. I may
have a related but I don’t think identical problem.
The issue, and the article cited is that some uploads (typically
“small”) files are treated as StringIO objects and others are TempFile
objects. Note from my error (with the spelling error fixed) that it
appears I’m returned a String not a StringIO object.
undefined method `content_type’ for “scandata.txt”:String
I did change my little test from .content_type to .read which StringIO
does support and it also failed.
I happen to be developing for the very first time on an OSX and I am
going to try and repeat this on a linux system.