Since Ajax doesn’t support file uploads, I’m using “IFRAME remoting
made easy” (http://sean.treadway.info/). I’m saving a file to the
filesystem, and then trying to put it in to the database when I do the
final submit with ajax. I thought picking the file up and putting it
in the db would be as easy as having:
"@image.data = IO.read(“path_to_file”) in the create method in the
controller. But I get: “undefined method `read’ for #”
What’s the right way of doing this?
On Jun 4, 2006, at 4:57 PM, Henrik Ormåsen wrote:
"@image.data = IO.read(“path_to_file”) in the create method in the
controller. But I get: “undefined method `read’ for #”
What’s the right way of doing this?
Try IO.readlines(“path_to_file”).join instead of IO.read
HTH,
Dmitry Sabanin
http://futuretrack5.com | http://sabanin.ru/en
Sun, 04 Jun 2006, Dmitry V. Sabanin skrev:
On Jun 4, 2006, at 4:57 PM, Henrik Ormåsen wrote:
"@image.data = IO.read(“path_to_file”) in the create method in the
controller. But I get: “undefined method `read’ for #”
What’s the right way of doing this?
Try IO.readlines(“path_to_file”).join instead of IO.read
That didn’t help. I still get “undefined method `read’ for #” :-(.
Hi Henrik,
On Jun 4, 2006, at 4:57 PM, Henrik Orm�sen wrote:
"@image.data = IO.read(“path_to_file”) in the create method in the
controller. But I get: “undefined method `read’ for #”
What’s the right way of doing this?
Try IO.readlines(“path_to_file”).join instead of IO.read
That didn’t help. I still get “undefined method `read’ for #” :-(.
If you changed a line containing ‘IO.read’ to ‘IO.readlines’ and you’re
still getting a message that says, in part, “undefined method ‘read’ for
#”
then your code is not failing at that line. If it were, you would be
getting a message that says “undefined method ‘readlines’ for #”
If you look more closely at the error message RoR is giving you, it
tells
you the controller | view | model / method / line number that caused the
error. It’s not all in one line, but it’s all there.
hth,
Bill
Henrik =?iso-8859-1?Q?Orm=E5sen?= wrote:
Sun, 04 Jun 2006, Dmitry V. Sabanin skrev:
On Jun 4, 2006, at 4:57 PM, Henrik Orm�sen wrote:
"@image.data = IO.read(“path_to_file”) in the create method in the
controller. But I get: “undefined method `read’ for #”
What’s the right way of doing this?
Try IO.readlines(“path_to_file”).join instead of IO.read
That didn’t help. I still get “undefined method `read’ for #” :-(.
That’s very odd. Ruby doesn’t think you’re using the standard IO class.
Are you certain you haven’t redefined that class somewhere else in your
code? Alternatively…try reinstalling ruby?