Wednesday, 18 September 2013

Organizing rails controllers within namespaces

Organizing rails controllers within namespaces

I have a fairly simple question about the code organization of rails
controllers:
If we have an app store platform (i.e. Google Play) which consists of
Developers (They create/upload the apps), Admins (Review and approve the
apps) and Users (Who consume the apps via the store).
The developers do everything through the developers platform, so it would
make sense to have a developers namespace to group related items. The same
logic would seem to make sense for the admin, give them an admin panel
under an admin namespace.
Now here's the question - I have two namespaces, Admin and Developer - if,
a developer can change an app's state from :draft to :pending (for review)
and the admin can change the state from pending to :approved/:rejected,
where is the recommended place to store apps_controller.rb?
There seems to be three ways to handle this and I'm not quite sure which
is the most 'correct', either for practical reasons or conventional
reasons. The three options I can think of are:
1) In both the Admin & Developer namespace (and populate the store from
developer::apps)? 2) Only in the Developers namespace 3) The
apps_controller should not live in either namespace.
Thanks in advance!

No comments:

Post a Comment