# Admin section and public site

**URL:** <https://www.ruby-forum.com/t/admin-section-and-public-site/173206>\
**Category:** Rails\
**Created:** [August 4, 2009, 10:47pm UTC](https://www.ruby-forum.com/t/admin-section-and-public-site/173206 "2009-08-04T22:47:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![klaus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e99b99/32.png) [@klaus](https://www.ruby-forum.com/u/klaus)\
**Post date:** [August 4, 2009, 10:47pm UTC](https://www.ruby-forum.com/t/admin-section-and-public-site/173206/1 "2009-08-04T22:47:51Z")

</div>

Hi,

I’m learning rails. Just started some month ago. I’ve got some years  
of experience with php and now I’ve realized rails makes a lot more  
fun.

But anyways, I have a question. There is something I don’t understand.

How would you do a rails app like this?  
Admin section: a cool rails app for CRUD of some I call them documents  
(i.e. document model) and for setting some parameters and so on  
Public (LAN) site: another cool rails app mostly for navigating within  
the document repository and for writing comments and so on

Is there a straight rails way to do this? I mean I don’t want to have  
redundancies in code or other design mistakes.

Should there be two separate apps or only one? And how to separate the  
two sections for security reasons while linking them by the models for  
design reasons?

Thanks for all interesting replies!

---

<div class="post-metadata">

**Author:** ![klaus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e99b99/32.png) [@klaus](https://www.ruby-forum.com/u/klaus)\
**Post date:** [August 4, 2009, 11:10pm UTC](https://www.ruby-forum.com/t/admin-section-and-public-site/173206/2 "2009-08-04T23:10:41Z")

</div>

Hi Klaus,

I guess you are talking about setting up an admin section for  
maintenance of the docs and one section for publi viewing of the docs,  
I guess a way to do this is to set up an admin area (by designating a  
folder called admin within your application) - then put th  
controllers, models for the admin section inside this folder. you can  
even have same name models/ controllers as the public site inside this  
folder.

Not sure if this is what you asked for - but maybe it will help.

D

---

<div class="post-metadata">

**Author:** ![klaus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e99b99/32.png) [@klaus](https://www.ruby-forum.com/u/klaus)\
**Post date:** [August 4, 2009, 11:19pm UTC](https://www.ruby-forum.com/t/admin-section-and-public-site/173206/3 "2009-08-04T23:19:28Z")

</div>

That’s not what I’m looking for.

I’m looking for a DRY solution.  
At least the document model should not repeat.

---

<div class="post-metadata">

**Author:** ![klaus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e99b99/32.png) [@klaus](https://www.ruby-forum.com/u/klaus)\
**Post date:** [August 4, 2009, 11:35pm UTC](https://www.ruby-forum.com/t/admin-section-and-public-site/173206/4 "2009-08-04T23:35:16Z")

</div>

On Aug 4, 2009, at 2:18 PM, Klaus wrote:

> That’s not what I’m looking for.  
> I’m looking for a DRY solution.  
> At least the document model should not repeat.

It’s close. Just create a set of controllers/views for your admin  
stuff. I tend to put them into app/controllers/admin and app/views/  
admin. Then this all gets password protected.

I use the same models that the public facing website uses that live in  
app/models.

This is DRY in the sense that (presumabely) what you are doing in the  
admin section is quite different than what the public can do.

If you want to blend them all together you’re free to do that too.

All depends on what makes the most sense for your app.

---

<div class="post-metadata">

**Author:** ![klaus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e99b99/32.png) [@klaus](https://www.ruby-forum.com/u/klaus)\
**Post date:** [August 5, 2009, 8:23am UTC](https://www.ruby-forum.com/t/admin-section-and-public-site/173206/5 "2009-08-05T08:23:15Z")

</div>

On 4 Aug., 23:34, Philip H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It’s close. Just create a set of controllers/views for your admin  
> stuff. I tend to put them into app/controllers/admin and app/views/  
> admin. Then this all gets password protected.
> 
> I use the same models that the public facing website uses that live in  
> app/models.
> 
> This is DRY in the sense that (presumabely) what you are doing in the  
> admin section is quite different than what the public can do.

And there are no problems to expect this way? I want to create a  
subdomain with a route to the admin section. I’ve already tested the  
ssl and subdomain things in rails, they’re looking great.

Back to my first question: Is this the only recommandable way to build  
an admin section? Is it possible to create two apps and one is  
“linked” to the other? What I mean is: The public app would use some  
things (like models) from the admin app, and all rails magic would be  
available.
