Mail Gem: Render received email in browser / Full parse of html parts - ruby-on-rails

I am working with the Mail Gem to receive emails in my Rails 4 application. The mails are grabbed via POP from a mailbox, every 10 minutes or so, via the Gem.
I need to render these emails - mostly in HTML format - and am having trouble saving the body in HTML, not to mention working with things like embedded images. I'm probably missing something here- looked all over StackOverflow but haven't seen an answer to related questions yet.
I have been working with
message.body.decoded
and also looked at the html_part v. text_part - but I don't see a method to get to just the enclosed HTML. Looks like I need to strip the headers, which the Mail Gem seems to leave in the body- then also deal with any inline attachments. Surely a gem for this must exist..? Or an approach...? Your advice is valued.
I did find the Mailcatcher Gem - but that is really its own Sinatra app. I might just try adapting this gem but that appears to be a lot of work. Surely someone else has already dealt with this problem..?
I would also value a suggestion on how to best store the message body in MySQL - am thinking large text or blob type.
Thank you!

I use letter opener
It works fine... And if you are using vagrant as the main development machine you you can use this
Letter opener web

Related

Testing microdata in Gmail doesn't work

I've found some interesting pieces of code on Google Schemas and I know that the only way to test it without being whitelisted is sending mails to yourself, but my problem is that even that doesn't really work for me.
I've tried countless examples in both formats, but only the Flight Reservation and the Go-To Action are working at all... Even though I let everything run through Google's markup validator before testing and it turned out to be valid.
So... does anyone know if this is an error that lies with Google (missing functionality, wrong examples, faulty markup tester, ...) or am I in fact missing something which is the reason why it doesn't work?
(I'm sending/receiving the emails through the normal Gmail inbox in Firefox version 33.0. In case it's important, I'm using a Laptop with Ubuntu 14.04.1 LTS)
The functionality is still missing from Gmail. In other words, no one at Google working at Gmail has coded any functionality to pick up, for example cooking recipies.

Ruby functions to send Twilio fields from XML feed

I'm Ruby n00b, so please excuse my first question.
I've got my Rails environment up on a web server up, and now I am trying to find a Ruby functions (methods?) that would allow me to do the following:
Function 1
suck in an XML feed from another website
cherry pick a particular field from that XML field (e.g. email addr or phone)
Function 2
send that particular XML field to phone number via Twilio.
Any suggestions on where to start would be helpful. (Even if it's to tell me to RTFM)
For your first function, you don't need to do anything with Twilio. I presume you want to parse an XML feed to get specific data from it.
You can use a gem like nokogiri to parse XML, have a look at this similar SO question to learn how:
Parsing XML with Ruby
There's tons of other resources on parsing XML using ruby here to:
https://www.google.ca/search?q=parse+xml+ruby&rlz=1C1CHFX_enCA552CA552&oq=parse+xml+ruby&aqs=chrome..69i57j0l5.3359j0j7&sourceid=chrome&es_sm=122&ie=UTF-8
For your second function, this is where you'll actually be using Twilio. First off, I'm assuming you've setup Twilio, if not, head over to and sign up:
https://www.twilio.com/
You'll want to add the Twilio ruby client in your Gemfile:
gem 'twilio-ruby'
Be sure to bundle install and if everything is good, you are ready to code your Twilio interaction. Assuming from fn1 you have the data in a variable, you'll now need to send it via SMS/MMS, here's the Twilio guide for that:
https://www.twilio.com/docs/quickstart/ruby/sms/sending-via-rest

Rails: "Waiting" HTML screen while PDF is being generated

I have a Rails app that can generate PDFs using Prawn. Some of them can be fairly large (tens or hundreds of pages) and take some noticeable time to generate. What I would like to do is display some HTML page with a message like "Please wait while we create your document (spinning icon)", and then display the PDF once it is done.
I was thinking of using Rack Middleware to do this. Admittedly, I know nothing about Rack except having watched Railscasts Episode #151. It seems like I could intercept the request to these large PDFs, display the HTML waiting page, then intercept the response and replace the HTML with the generated PDF content.
Is this possible? Will this work with Rack? If not, what is something that might accomplish this? If it will work with Rack, can someone give me a generic explanation of the steps to do this? I've been searching the internet, and the Rack stuff I've found isn't very beginner-friendly (thus, I'm asking here).
Any help will be much appreciated.
Ian
Not sure that this is what you want, but you can send message to the browser via something like private_pub after PDF is ready and handle receiving of that message on the client side (show a link, start download etc).

how to send notification to another user in rails

im trying to create a badge system similar to stackoverflows. i noticed that stackoverflow is able to send a notification to another user. for example, if i create a question, and 10 people upvoted my question, i receive a badge, not the current_user doing the upvoting.
how can i do that in rails? it seems sending a message to another user is out of the scope of flash messages. i did some research and maybe the faye gem seems like a possibility? however im not positive though. i was watching the railscasts and it seemed maybe better for a chatting system? is push-notification the way to go?
what would be a good way to do this? thank you
I can suggest to use this gem: https://github.com/dapi/gritter_notices
It is well handle with this problem, but it has two drawbacks:
Documentation on russian
Binding to the gritter
If you choose to use it, see what version of gritter you use. As I remember, the version of original gritter gone forward a bit.
This part of code does what you need.

How do I grab meta data from other websites and display on mine in ruby on rails?

When using FB or Google + I can paste a link of any website into the status update box and it will instant load information about that website with the option of flicking through thumbnail images.
How can I go about achieving this in ruby on rails? All my searches seem to bring up php methods on how to do this.
For grabbing video data info I use the Ruby Open Graph Protocol gem. Is there any thing for grabbing data the way FB and G+ do? If not is there a standard way this is done in rails/ruby, if so.. how is this done?
Kind regards
I think you're looking for something like oembed. I've found a gems for that, so I propose you to take look at it: https://github.com/judofyr/ruby-oembed or https://github.com/embedly/embedly-ruby
You should likely use a gem like http://nokogiri.org/
It allows you to work with a html page just as you would do with jQuery. Very handy.

Resources