# Embedding Rails in a Cocoa app

**URL:** <https://www.ruby-forum.com/t/embedding-rails-in-a-cocoa-app/76799>\
**Category:** Rails\
**Created:** [November 21, 2006, 9:11am UTC](https://www.ruby-forum.com/t/embedding-rails-in-a-cocoa-app/76799 "2006-11-21T09:11:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukeda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/51bf81/32.png) [@lukeda](https://www.ruby-forum.com/u/lukeda)\
**Post date:** [November 21, 2006, 9:11am UTC](https://www.ruby-forum.com/t/embedding-rails-in-a-cocoa-app/76799/1 "2006-11-21T09:11:39Z")

</div>

Hi,

Has anyone tried to embed rails into a Cocoa app? I have got this  
working to a very primitive point using RubyCocoa. After about half an  
hour of playing I was able to get WEBrick to serve the rails starter  
page inside of a Cocoa app, but that is as far as I have got.

I have an idea for a client/server app where the server is a Cocoa  
application that embeds WEBrick (or another server solution possibly)  
that serves a rails app that interfaces with the running Cocoa  
application via the RubyCocoa bridge.

Is this naive? It seems to me that it should be possible, but I am  
fairly new to Rails and semi-new to Ruby. I am also kind of looking for  
some reassurance that this isn’t a totally ridiculous idea before I  
invest all my time in it.

Thanks for any input.

- Luke.

---

<div class="post-metadata">

**Author:** ![lukeda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/51bf81/32.png) [@lukeda](https://www.ruby-forum.com/u/lukeda)\
**Post date:** [November 21, 2006, 11:06am UTC](https://www.ruby-forum.com/t/embedding-rails-in-a-cocoa-app/76799/2 "2006-11-21T11:06:22Z")

</div>

Luke D. wrote:

> Hi,
> 
> Has anyone tried to embed rails into a Cocoa app? I have got this

James Duncan Davidson recently shipped some kind of book application.

hold on…

/me googles

> **[Download Bookshelf](https://support.vitalsource.com/hc/en-us/articles/201344733)**
>
> Download Bookshelf
> 
> Please visit our Parent Page for the latest Bookshelf downloads.

[http://blogs.pragprog.com/cgi-bin/pragdave.cgi/Random/VitalSource.html](http://blogs.pragprog.com/cgi-bin/pragdave.cgi/Random/VitalSource.html)  
[http://blog.duncandavidson.com/2005/08/its\_official.html](http://blog.duncandavidson.com/2005/08/its_official.html)

It’s a thick client for multiple platforms with rails embedded (I  
think).

Alan

---

<div class="post-metadata">

**Author:** ![lukeda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/51bf81/32.png) [@lukeda](https://www.ruby-forum.com/u/lukeda)\
**Post date:** [November 21, 2006, 5:53pm UTC](https://www.ruby-forum.com/t/embedding-rails-in-a-cocoa-app/76799/3 "2006-11-21T17:53:59Z")

</div>

Running rails inside of cocoa sounds like a cool/fun idea, but I can’t  
comment on if this is the right approach without knowing more about  
what you are trying to accomplish.

Why do you need Cocoa to “wrap” the server. Do you want to do this so  
it is easier to install? Do you want to do this so that you can setup  
the Cocoa app to configure/modify the rails server? If you’re using a  
database, you might consider using Cocoa’s Core Data to connect to the  
same database as your rails application. (and have them work together  
that way).

---

<div class="post-metadata">

**Author:** ![lukeda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/51bf81/32.png) [@lukeda](https://www.ruby-forum.com/u/lukeda)\
**Post date:** [November 22, 2006, 3:43am UTC](https://www.ruby-forum.com/t/embedding-rails-in-a-cocoa-app/76799/4 "2006-11-22T03:43:46Z")

</div>

The reason for running inside of a Cocoa app is that Rails will be  
communicating with the actual application via the RubyCocoa bridge. I  
don’t want to give away too many details at the moment considering I am  
just trying to get a proof of concept thing going. The whole premise  
here is that the client component of the application is actually a web  
app which brings cross platform goodness.

A bit of a breakdown…

The server application will be a Cocoa application that interacts with  
various other running applications on that machine. The server app  
embeds a rails app which provides a way for clients to utilise the  
application. Using RubyCocoa, I hope to get the rails app capable of  
calling into the Objective-C runtime of the application to make things  
happen.

Does that explain what I am trying to do?

---

<div class="post-metadata">

**Author:** ![lukeda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/51bf81/32.png) [@lukeda](https://www.ruby-forum.com/u/lukeda)\
**Post date:** [November 22, 2006, 3:49am UTC](https://www.ruby-forum.com/t/embedding-rails-in-a-cocoa-app/76799/5 "2006-11-22T03:49:47Z")

</div>

After a quick browse, this seems slightly different.

It seems to be that the client is embedded (via WebKit), but the server  
aspect is operating in a more traditional sense.

Thanks for the links though (y)
