# Optional Rails app functionality

**URL:** <https://www.ruby-forum.com/t/optional-rails-app-functionality/138140>\
**Category:** Rails\
**Created:** [May 20, 2008, 3:58pm UTC](https://www.ruby-forum.com/t/optional-rails-app-functionality/138140 "2008-05-20T15:58:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![djmook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@djmook](https://www.ruby-forum.com/u/djmook)\
**Post date:** [May 20, 2008, 3:58pm UTC](https://www.ruby-forum.com/t/optional-rails-app-functionality/138140/1 "2008-05-20T15:58:33Z")

</div>

Hi,

I’ve got this idea and/or  
requirement-with-no-known-solution-so-I-made-one-up.

Here’s my problem: Say I’ve got a rails app that does a bunch of stuff.  
Great.  
Now I want to create an admin section to maintain users and do special  
secret & secure stuff. This function is part of my rails app: it would  
make use of the same models, helpers etc, but I want to treat it  
seperately.  
Also, when I release my rails app, I don’t want the admin section to be  
included. The admin section would only be released to an internal  
server, for added security.

I don’t think that a plug-in or gem is an appropriate solution, since  
I’m not making a change to the language or the rails framework: this is  
purely within the application scope. And, really, I’d like to  
development the admin functionality the same way I would develop the  
rest of the app - with a rails file structure, and ‘feel’.

What I’d really like to do is have a seperate app, and link the two.  
Maybe some mechanism where two seperate rails apps can share their model  
space, but could be treated as seperate entities (maybe having different  
git repos and release mechanisms). I hape that’s a clear explanation.

Another example where this sort of thing micht be useful: Say you got  
some web site created with rails. You want to have a blog on your site  
and integrate some useful blog function with other pages in your site.  
You decide that Typo is an awesome blogging app, but what do you do  
next? How can you create a page that has some of your app, plus some  
blogging features from typo?

Typo is a distinct rails app, so the only thing I can think of is  
‘merging’ your two apps into one super-app, but then everything gets  
really messy and your whole source code control goes down the toilet.

How marvellous it would be if you could add a line to your app config  
that said ‘include\_app /…/…/typo’ and you could access the models and  
controllers of a completely independant rails app within your app. Kinda  
like making entire rails apps ‘pluggable’.

Is there already a standard approach for solving the sort of problem I’m  
describing? Or have I thought of something totally new and awesome? 😉

Thanks, Mark.

---

<div class="post-metadata">

**Author:** ![djmook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@djmook](https://www.ruby-forum.com/u/djmook)\
**Post date:** [May 20, 2008, 4:07pm UTC](https://www.ruby-forum.com/t/optional-rails-app-functionality/138140/2 "2008-05-20T16:07:16Z")

</div>

On 20 May 2008, at 14:58, Mark C. wrote:

> secret & secure stuff. This function is part of my rails app: it would  
> purely within the application scope. And, really, I’d like to  
> development the admin functionality the same way I would develop the  
> rest of the app - with a rails file structure, and ‘feel’.
> 
> What I’d really like to do is have a seperate app, and link the two.  
> Maybe some mechanism where two seperate rails apps can share their  
> model  
> space, but could be treated as seperate entities (maybe having  
> different  
> git repos and release mechanisms). I hape that’s a clear explanation.

Grungy: add the other app’s model folder to your app’s load paths.  
Less grungy: put common models in a plugin which both apps include. or  
svn:externals the models of one app into the other app.

Fred

---

<div class="post-metadata">

**Author:** ![djmook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@djmook](https://www.ruby-forum.com/u/djmook)\
**Post date:** [May 20, 2008, 6:31pm UTC](https://www.ruby-forum.com/t/optional-rails-app-functionality/138140/3 "2008-05-20T18:31:33Z")

</div>

Even less grungy (IMO)  
ActiveResource – that’s what it’s all about.

On May 20, 10:06 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![djmook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@djmook](https://www.ruby-forum.com/u/djmook)\
**Post date:** [May 22, 2008, 2:26pm UTC](https://www.ruby-forum.com/t/optional-rails-app-functionality/138140/4 "2008-05-22T14:26:32Z")

</div>

> Grungy: add the other app’s model folder to your app’s load paths.

I haven’t tried this yet, but I assumed that it wouldn’t be as easiy as  
that, since there could be all sorts of configuration that might be set  
up in the original directory (which could, for example be connected to a  
different database). I was assuming that you’d need to add a bunch of  
references to other helpers, configs, etc, but even that would’t be  
sufficient, since if you are running a single rails app, you’d need some  
way to assort that some models are configured _this_ way, whilst others  
are configured _that_ way.

> Less grungy: put common models in a plugin which both apps include. or  
> svn:externals the models of one app into the other app.  
> WRT the typo example, I’m looking for a solution that lets me take a  
> whole app and treat it kind of like a plug-in. By that I mean that I  
> want to be able to download an app like typo and set it up, but I don’t  
> want to have to spend a lot of time modifying it (like splitting it up  
> inta a plugin, re-testing it, applying maintanance patches to my ‘typo  
> plugin’ if the typo app is updated, etc.

> Even less grungy (IMO)  
> ActiveResource – that’s what it’s all about.

I thought about that just as I finished my original post, but I hadn’t  
really had a play with it, so I held my tounge.  
I have a couple of questions.  
Say I have my app that I want to make use of typo with. Does typo have  
to be written in a particular way? (other than having a RESTful http  
interface?)

In my description above of having a seperate admin app for security, I’m  
kinda assuming I’m not going to achieve any security benefits if my  
original app exposes enough via activeresource to enable an admin app to  
function.

It also has a couple of disadvantages I can think of. It must be  
relatively slow, givin the communication overhead. It also requires  
another app server to be running (although that could equally be an  
advantage, if considering scalability).

Thanks for your advice!
