Image Files

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

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
[email protected]

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/

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

On Aug 15, 2:54 pm, shusseina [email protected] 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}" %>

On Aug 16, 3:36 am, shusseina [email protected] 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: #[email protected]}" %>

because the document root is public: that path should be /images/
the_god_father.jpg

Rred

On Aug 16, 7:01 pm, Frederick C. [email protected]
wrote:

<%= "Plot: #[email protected]}" %>

because the document root is public: that path should be /images/
the_god_father.jpg

Too easy, thanks!

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
[email protected]