Forum: Ruby on Rails How to Upload Image through RoR??

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8c70506408fddb9740b4de7339055c77?d=identicon&s=25 Prashant Tiwari (tiwaripk)
on 2006-04-05 14:40
Hi,

I have one form , in which I am using file_field teg for input image
file as follows.
=====
<%= file_field("store", "picture") %>
=======
Tha Actual fileld name of my Image field in Database is "store_photo"
with datatype LargeBLOB.
& Inside my Store Model I have specified "def picture" as follows:-
=========================
def picture=(picture_field)
    self.store_photo = picture_field.read
end
=========================

Now When I am trying to Uplaod file by submitting form I am getting
error like:-
======================================
undefined method `read' for "logo.gif":String
======================================
Why I am getting this error? PLease tell me how to upload file into my
database from a form & also if later I want to retrieve that image from
database & display it on page how to do it?

Thanx.
Prash
4daf0b71d5d9a3882e583c0e72eaf5dc?d=identicon&s=25 Alan Francis (Guest)
on 2006-04-05 14:54
Prashant Tiwari wrote:
> Why I am getting this error? PLease tell me how to upload file into my
> database from a form & also if later I want to retrieve that image from
> database & display it on page how to do it?

Hi Prashant,

I'm sorry to be the first to do this, but I'm calling Help Vampire. <
http://slash7.com/pages/vampires >

Have you looked at the documentation for file_field ?  It looks like
what you think is the object is actually just the filename.  Perhaps
file_field documentation can help you diagnose this problem.

You might also consider whether any changes need to be made to the form
itself to facilitate a multiple part submission, file data and params.

A.
9d1f5d2d9de70bd9a934f557dc95a406?d=identicon&s=25 Daniel ----- (liquid)
on 2006-04-05 14:58
(Received via mailing list)
Take a look at file_column

Should do what you want

http://wiki.rubyonrails.org/rails/pages/File+Column+Plugin
89d967359903c639d31e4cad4569f537?d=identicon&s=25 Charlie Bowman (Guest)
on 2006-04-05 15:01
(Received via mailing list)
This is exactly why the "Help Vampire" Post pissed me off so much.  It's
a stupid phrase and should never be used.  That post will do more damage
to the community than 1 million "bad" questions.
4daf0b71d5d9a3882e583c0e72eaf5dc?d=identicon&s=25 Alan Francis (Guest)
on 2006-04-05 15:11
Charlie Bowman wrote:
> This is exactly why the "Help Vampire" Post pissed me off so much.  It's
> a stupid phrase and should never be used.  That post will do more damage
> to the community than 1 million "bad" questions.

You may be entirely correct.  I hovered a while before sending, not at
all sure whether to do it or not.  Apologies if it offended anyone, but
I feel the rest of the mail stands.

A.
4daf0b71d5d9a3882e583c0e72eaf5dc?d=identicon&s=25 Alan Francis (Guest)
on 2006-04-05 15:26
Alan Francis wrote:
> Charlie Bowman wrote:
>> This is exactly why the "Help Vampire" Post pissed me off so much.  It's
>> a stupid phrase and should never be used.  That post will do more damage
>> to the community than 1 million "bad" questions.
>
> You may be entirely correct.  I hovered a while before sending, not at
> all sure whether to do it or not.  Apologies if it offended anyone, but
> I feel the rest of the mail stands.
>
> A.

And FWIW, I agree it's a stupid name for a very real thing.

A.
678aa0aabf79a4933b7efc6d585dc141?d=identicon&s=25 Matt White (Guest)
on 2006-04-05 15:54
(Received via mailing list)
I agree with the principle, and I agree that it is real. As a reforming
.NET
user, I can attest to the pitiful state of many of the various
communities
because of this very real problem. Nothing is more frustrating than a
list
being overwhelmed with questions from those who won't take the time to
do a
tiny bit of research before asking someone else to do it for them.

A community is about give AND take. If you take too much, people ignore
you,
and if everyone only takes, then the community disintegrates.

Matt
This topic is locked and can not be replied to.