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?
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.
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.
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.