I’ve a simple web app that concerns employee’s and their
(work/lunch)shifts. I’ve succesfully included HABTM relations between
the two tables and all works fine. But now I want to make a distinction
between employee’s (who are also users of the web app) that are ‘mere’
users or those that may administer the app.
Now I have two controllers, one for employee and one for shift. Also I
have one controller for login. I need some hints to maintain the DRY
principle of rails and also have pretty URL’s (as admin it needs to be
like /admin/shifts/edit and for user like /shifts/view or something).
For example I want the admin and normal user to share some views on
data, but most of their views will be different.
It is recommended to put all actions for one database table in one
controller, hence that I’ve created the employee and shifts tables, but
now I am at a loss where to put and how to name the controllers (perhaps
I have to divide the employee and shifts controllers into user and
admin?) that control the user actions and admin actions.
I hope some of you have more experience with this thing and can give me
some hints on how to set-up this architecture.
I assume you mean this piece of code should be in the config/routes.rb
file? It tells me that namespace is not known method, but I understand
now (after reading the routes chapter of my book) that the URL is not
dependent on the controller architecture, but it can be changed later.
The question that remains is whether I should put user actions and admin
actions in seperate controllers (because they maintain different filters
for access) or if it is best if they are combined and written in their
corresponding table_controller (all actions referring to one
object/model/table in one controller)?