How to upload and mail the same attachment file in rails 4? - ruby-on-rails

I am using rails 4.
Can any one please suggest , what is the best way to upload a pdf file and the same time mail this file?

For uploading, you can use the CarrierWave library. Is pretty easy to use. And for sending an Email, you can follow this part of the Rails Tutorial Book which shows you how to setup and send emails.

Related

generating password protected pdfs using rails

Recently I was looking for some gem which can password protect our existing pdf files.
Basically we are fetching some invoice PDFS from aws . After fetching it from aws , we have to add password to the pdf and send it as an attachment in an email.
I tried with prawn/hexapdf/combined_pdf , but no success. Because with prawn i can not find a way to read an existing pdf. but prawn can easily password encrypt any pdf generated via prawn.
Any suggestion would be greatly appriciated.
Not really a gem, but is it possible to install and use a command line program like pdftk? I've been using it for years for similar problems with great success.

how can I upload and download files in rails application

I am new to rails and i am making an application which will upload a file(text), and then after some processing on the file, i want to download it and delete the original file. Also specify if there is some online source on this.
You can use a file input just like any other rails form input.
http://guides.rubyonrails.org/form_helpers.html#uploading-files

How might I be able to link jquery file upload, ajax, and jquery file download on rails?

Thanks!
I'm a complete beginner but I'd like to know even in a generic way so that my users could upload a file to another user's directory, the file gets saved on to a server and the receiving user could download it when the upload gets finished.
Since you're a complete beginner, I won't give you a lot of code; instead, I'll show you the overview of what you can do, and hopefully that will give you a much more refined approach to adopt:
Rails Uploads Using Paperclip
What makes Rails so powerful is the gem ecosystem - these are little plugins which give you functionality outside the scope of the Rails framework. You can get Gems for everything from file uploads to CSS frameworks - all for free
One of the most important & popular gems for Rails is Paperclip (and you have Carrierwave which also does the same job). These are what you use to process image uploads in Rails
Since you're a total beginner, you should really watch this Railscast about how to upload files with Rails using Paperclip:
There are also a lot of other tutorials on Paperclip:
Heroku's Paperclip Tutorial
Simple Paperclip tutorial
Another Paperclup tutorial
I would write some more updates about Paperclip & JQuery, but I think you should get your head around the upload process first

How should I parse a file in Ruby on Rails to store in a database?

I want to create a simple form for users to upload a file, which will be stored in a database. I also want to display all the submitted files in the database with their name and a link to download the file. Schematically, what's the best way to do this in Rails/how should I store the file in table (which fields should my table have? etc). Thanks!
i would use paperclip gem with the upload to s3 instead of file system
https://github.com/thoughtbot/paperclip
checkout the README, most of the examples are for an image, but works with non-image files as well
use paperclip to upload file, you can store images/file in your database as well as in s3 (AWS)
See below link how to use paperclip in rails with example
Here is the steps how to upload file using paperclip in rails
http://patshaughnessy.net/2009/4/30/paperclip-sample-app
for github
https://github.com/thoughtbot/paperclip
https://github.com/websymphony/Rails3-Paperclip-Uploadify

Rails > Upload image via email

Is there a rails plugin or gem out there that allows users to upload their image by emailing the image as an email attachment?
I would suggest you use the fetching code from here and then just use ActionMailer.receive to create an object from it/load the attachment.
You could have a look at mail which lets you create and read/parse emails.

Resources