# Using Rails MVC to handle non-HTTP requests

**URL:** <https://www.ruby-forum.com/t/using-rails-mvc-to-handle-non-http-requests/118003>\
**Category:** Rails\
**Created:** [October 23, 2007, 10:46am UTC](https://www.ruby-forum.com/t/using-rails-mvc-to-handle-non-http-requests/118003 "2007-10-23T10:46:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gcnovus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/779978/32.png) [@gcnovus](https://www.ruby-forum.com/u/gcnovus)\
**Post date:** [October 23, 2007, 10:46am UTC](https://www.ruby-forum.com/t/using-rails-mvc-to-handle-non-http-requests/118003/1 "2007-10-23T10:46:27Z")

</div>

I’m starting to think through a webapp that allows multiple connection  
types (HTTP/web, email, SMS, Twitter, etc), and I’d like to combine as  
much functionality as possible. To that end, I’ve been thinking about  
how to integrate the other media with Rails’ MVC. For each one, I’d  
like the input to be the same as the output (that is, if I send an SMS  
to the server, I get an SMS response).

I imagine creating fake MIME types for each one, and then having  
foo\_view.html.erb, foo\_view.sms.erb, foo\_view.twitter.erb, etc.

Some problems:

1. I can’t figure out how to dispatch to a controller. For example,  
if I have a daemon thread polling for email, how do I take the  
extracted email text and use it to set up the request for the  
controller? How do I then call the controller’s handle method?

2. Are Rails controllers really abstract enough for this? They seem  
quite tied to the AbstractRequest object, which is certainly HTTP.  
(Email has no concept of GET vs PUT or a URL, and HTTP has no concept  
of a Subject.)

3. Would I be better off choosing a different framework? I love  
Rails, but am I trying to cut a cucumber with my golden hammer?

-Gaius

---

<div class="post-metadata">

**Author:** ![gcnovus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/779978/32.png) [@gcnovus](https://www.ruby-forum.com/u/gcnovus)\
**Post date:** [October 23, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/using-rails-mvc-to-handle-non-http-requests/118003/2 "2007-10-23T13:24:49Z")

</div>

On 10/23/07, gcnovus [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 1. Would I be better off choosing a different framework? I love  
> Rails, but am I trying to cut a cucumber with my golden hammer?

Instead of having the daemons try to directly invoke rails  
controllers, why not have them simply make http requests themselves?  
You can have controllers actions in the rails app to deal with your  
(inner ) daemons.

You could use ActiveRecord perhaps together with ActionMailer to  
define models which the daemon, running in the environment of your  
Rails app under script/runner say, could put incoming information into  
the db for the controllers to access.

Since you apparently want the daemon to respond in an appropriate way,  
it would then be responsible for transporting the result of the http  
request back to the requester via e-mail, sms, etc.

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)
