bdeonovic
bdeonovic

Reputation: 4220

Rails: use image for a column in model

I want users to be able to upload an image and have it be associated with a particular model. When I create my migration, what type do I use for my column? In the view I would like it to look something like this:

<%= form_for @person, :html => {:multipart => true} do |f| %>
<%= f.file_field :picture %>
<% end %>

Thanks guys :)

Upvotes: 0

Views: 7570

Answers (3)

Ben
Ben

Reputation: 173

There's also the AWS-3 gem, if you just want cloud storage. I would think performance alone would be enough to not store an image in a DB.

Upvotes: 1

Martijn
Martijn

Reputation: 1719

I recommend the usage of an external plugin such as Paperclip or Carrierwave.

Upvotes: 2

Slick23
Slick23

Reputation: 5907

Probably :binary -- but, have you considered using something like Paperclip to handle image uploads for you? It can get really complicated otherwise.

Upvotes: 5

Related Questions