model-controller-paradigm: What about admin controllers?

Joshua Muheim
Sun, 10 Dec 2006 21:33:30 -0000

Hi all

We all know the model-controller-paradigm: I have a model "News" which
has a corresponding CRUD-controller "NewsController".

But now I''m quite unsure about the following...

Guess we have normal visitors that visit our site www.??.com/news and we
have administrators that create and modify news items.
The admin should see an "Edit" link and a "Destroy" link
corresponding
to every news item, but visitors should not see them. So we mix some
admin functions into the views.
Further on we need some methods like www.??.com/news/edit/:id that
should only be callable by an admin; we can easily secure this using a
before_filter or so.

So far so good. But the more complex our model becomes, the more we have
to mix admin logic with visitor logic.
So I guess it would be cleaner if we created not only one corresponding
controller, but two of them: a NewsController that is an interface
between data and visitors and a NewsAdminController that handles all the
CRUD-and-more stuff an admin can do.
Is this a good solution? I could then create a route that sends URL
calls like www.??.com/news to the NewsController and URL calls like
www.??.com/admin/news to the NewsAdminController...

Please tell me what you think about this. Are there better solutions for
separating user logic and admin logic?

Thanks for your interesting answers,
Joshua