# Image Files

**URL:** <https://www.ruby-forum.com/t/image-files/173799>\
**Category:** Rails\
**Created:** [August 15, 2009, 6:55am UTC](https://www.ruby-forum.com/t/image-files/173799 "2009-08-15T06:55:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![shusseina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d78d45/32.png) [@shusseina](https://www.ruby-forum.com/u/shusseina)\
**Post date:** [August 15, 2009, 6:55am UTC](https://www.ruby-forum.com/t/image-files/173799/1 "2009-08-15T06:55:23Z")

</div>

I’m a Rails newby and I’m in the process of creating my first Rails  
app - a knock-off of IMDb, albeit a ‘nano’ version of it.

When displaying the details of a movie I would like to show the  
movie’s (DVD) cover art. How do I store images in my sqlite3  
database? Should the (database) column be of type BINARY? Is there a  
Rails helper for uploading images via web page form?

Hope the above makes some sense to somebody.

Thanks  
Steve

---

<div class="post-metadata">

**Author:** ![shusseina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d78d45/32.png) [@shusseina](https://www.ruby-forum.com/u/shusseina)\
**Post date:** [August 15, 2009, 7:40am UTC](https://www.ruby-forum.com/t/image-files/173799/2 "2009-08-15T07:40:21Z")

</div>

shusseina wrote:  
[…]

> How do I store images in my sqlite3  
> database?

There has been lots of discussion on ths very topic. Much of it is  
recent (i.e., in the last month or two). Search the list archives.

Now to your question. Sqlite is inappropriate for production, and you  
probably shouldn’t really be using it for development. Use a real DB (I  
recommend PostgreSQL).

> Should the (database) column be of type BINARY?

No. Image data does not belong in the DB. Put it in the filesystem  
instead, and just store the filename in a text field in the DB.

> Is there a  
> Rails helper for uploading images via web page form?

There’s the Paperclip plugin, and also attachment\_fu. I’ve never used  
either, but more people seem to like Paperclip.

> Hope the above makes some sense to somebody.
> 
> Thanks  
> Steve

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![shusseina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d78d45/32.png) [@shusseina](https://www.ruby-forum.com/u/shusseina)\
**Post date:** [August 15, 2009, 8:44am UTC](https://www.ruby-forum.com/t/image-files/173799/3 "2009-08-15T08:44:14Z")

</div>

Marnen Laibow-Koser wrote:

> No. Image data does not belong in the DB. Put it in the filesystem  
> instead, and just store the filename in a text field in the DB.

The reason is simply so the webserver can serve images directly off the  
file  
system without touching any Ruby code.

> There’s the Paperclip plugin, and also attachment\_fu. I’ve never used  
> either, but more people seem to like Paperclip.

I worked for 2.5 years on a project that reproduced Paperclip from  
scratch (I  
got there just after the crew migrated the images _out_ of the  
database!), and  
now I would never serve images without it.

–  
Phlip  
[http://zeekland.zeroplayer.com/](http://zeekland.zeroplayer.com/)

---

<div class="post-metadata">

**Author:** ![shusseina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d78d45/32.png) [@shusseina](https://www.ruby-forum.com/u/shusseina)\
**Post date:** [August 16, 2009, 4:32am UTC](https://www.ruby-forum.com/t/image-files/173799/4 "2009-08-16T04:32:26Z")

</div>

> Now to your question. Sqlite is inappropriate for production, and you  
> probably shouldn’t really be using it for development. Use a real DB (I  
> recommend PostgreSQL).

This is my first app, so it’s not intended for production. Using  
Sqlite because as a newby that’s one less thing to worry about. As an  
Ingres developer I have to recommend Ingres as the open source  
database of choice (though I don’t pretend to know how well it  
currently works with Rails).

> No. Image data does not belong in the DB. Put it in the filesystem  
> instead, and just store the filename in a text field in the DB.

Right. I’m embararssed I asked that question.

> There’s the Paperclip plugin, and also attachment\_fu. I’ve never used  
> either, but more people seem to like Paperclip.

Thanks

---

<div class="post-metadata">

**Author:** ![shusseina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d78d45/32.png) [@shusseina](https://www.ruby-forum.com/u/shusseina)\
**Post date:** [August 16, 2009, 4:37am UTC](https://www.ruby-forum.com/t/image-files/173799/5 "2009-08-16T04:37:42Z")

</div>

On Aug 15, 2:54 pm, shusseina [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m a Rails newby and I’m in the process of creating my first Rails  
> app - a knock-off of IMDb, albeit a ‘nano’ version of it.
> 
> When displaying the details of a movie I would like to show the  
> movie’s (DVD) cover art.

Why is the image “the\_godfather.jpg” not being displayed, considering  
the following show view template? Or even when I include the full  
absolute path?

\<%= "#{@movie.rank}. #{@movie.title}" %\>

\<%= "Director: #{@movie.director}" %\>

\<%= "Release Date: #{@movie.release\_date.to\_date.to\_formatted\_s (:long\_ordinal)}" %\>

\<%= "Plot: #{@movie.plot}" %\>

 ![]()

---

<div class="post-metadata">

**Author:** ![shusseina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d78d45/32.png) [@shusseina](https://www.ruby-forum.com/u/shusseina)\
**Post date:** [August 16, 2009, 11:02am UTC](https://www.ruby-forum.com/t/image-files/173799/6 "2009-08-16T11:02:13Z")

</div>

On Aug 16, 3:36 am, shusseina [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Why is the image “the\_godfather.jpg” not being displayed, considering  
> the following show view template? Or even when I include the full  
> absolute path?
> 
> \<%= "Plot: #removed\_email\_address@domain.invalid}" %\>
> 
> ![]()

because the document root is public: that path should be /images/  
the\_god\_father.jpg

Rred

---

<div class="post-metadata">

**Author:** ![shusseina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d78d45/32.png) [@shusseina](https://www.ruby-forum.com/u/shusseina)\
**Post date:** [August 16, 2009, 6:07pm UTC](https://www.ruby-forum.com/t/image-files/173799/7 "2009-08-16T18:07:07Z")

</div>

On Aug 16, 7:01 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > \<%= "Plot: #removed\_email\_address@domain.invalid}" %\>
> > 
> > ![]()
> 
> because the document root is public: that path should be /images/  
> the\_god\_father.jpg

Too easy, thanks!

---

<div class="post-metadata">

**Author:** ![shusseina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d78d45/32.png) [@shusseina](https://www.ruby-forum.com/u/shusseina)\
**Post date:** [August 17, 2009, 5:30pm UTC](https://www.ruby-forum.com/t/image-files/173799/8 "2009-08-17T17:30:50Z")

</div>

shusseina wrote:  
[…]

> This is my first app, so it’s not intended for production. Using  
> Sqlite because as a newby that’s one less thing to worry about.

I’m not sure it’s one less thing to worry about. Setup may be easier,  
but I gather that SQLite (which I’ve never used, so take this for what  
it’s worth) will run you into a wall with its limited query syntax and  
nonexistent concurrency support.

> As an  
> Ingres developer I have to recommend Ingres as the open source  
> database of choice (though I don’t pretend to know how well it  
> currently works with Rails).

I didn’t even know the Ingres project was still alive! What can Ingres  
offer a Rails developer that PostgreSQL cannot? It would be interesting  
to know.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
