开发者

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 %>
&开发者_开发问答lt;% end %>

Thanks guys :)


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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜