How to upload a file in rails?

althaf_tvm picture althaf_tvm · Oct 14, 2010 · Viewed 20.6k times · Source

I'm new to rails. I want to know about file uploading process in rails. Can anyone please help me... Thanks, Althaf

Answer

Jason stewart picture Jason stewart · Oct 14, 2010

Usually gems/plugins are used to to handle file uploads. My favorite one, and perhaps the most ubiquitous is Paperclip.

In your view, you'll have to tell the rails form helpers that you're uploading a file like this:

<%= form_for @model, :html => { :multipart => true } do |form| %>