Janak
Janak

Reputation: 5085

How do I add file uploads to a rails app?

I need to add the ability to upload and store any kind of file, PDF, XLS, DOC, etc. What is the best way to do this in a ruby on rails application?

Upvotes: 1

Views: 1411

Answers (4)

Felix Andersen
Felix Andersen

Reputation: 1391

I've worked with two of the big players when it comes to file uploads. carrierwave and paperclip.

They provide a good solution for a common task with support for different storage alternatives. Both support filesystem and S3. Carrierwave also supports Rackspace Cloud Files and MongoDB’s GridFS.

I would recommend carrierwave because of one aspect where they are different to use. It uses a separate upload class that you mount on your model. This separates your code related to the file upload from the model code. I find this approach cleaner and easier to test.

Upvotes: 0

Anubhaw
Anubhaw

Reputation: 6068

you can also look at attachment_fu rails.

Upvotes: 0

Shreyas
Shreyas

Reputation: 8757

I think this is exactly what you're looking for.

Upload files.

Upvotes: 6

Fran
Fran

Reputation: 1073

I'd recommend you to use paperclip or carrierwave both are really good libs and work out of the box in most cases.

Upvotes: 4

Related Questions