Rails way to structure admin / user / public controller

The fictitious Rails application has the following resources:

Photographers
Images
Comments

A Photographerhas many Imagesthat have manyComments

Each photographer has a login and can view, upload, edit and delete their images, comments, as well as their own profile.

An administration interface is available and can edit images, photographers and comments.

In addition, the photographer, their images and their comments are accessible from an open interface without logging in, where visitors can add comments.

My question is: what is the Rails way to structure controllers? I thought about going with namespaces for each role (public, account, admin) as follows:

# For administrator
Admin::PhotographersController
Admin::ImagesController
Admin::CommentsController

# For a logged in photographer
AccountController (?)
Account::ImagesController
Account::CommentsController

# For public
PhotographersController
ImagesController
CommentsController

- . , DRY?

!

+5
2

, account/admin. , ImagesController, , . ApplicationController . ImageController ImagesController. / , , require_admin, , , current_user admin, , .

+3

, . , , :

resources :photos, :only => [:index, :show] # offer only index and show actions to public 

scope "/admin" do
  resources :photos # full access for logged in users
end

, , (, ).

- , no/admin/sections . , , . : P

+2

All Articles