Topic: Design Suggestions
Since this is about application design, and not a specific question about any one piece of code, I felt it belonged here. Feel free to move it if this is the inappropriate place.
I am a Rails beginner, and my design-fu is weak (well, weak is a strong word...I know exactly what I want, so I guess my Rails-fu is weak).
I've watched Ryan's excellent Railscasts on administration, but it only slightly touches on what I want to do.
I have about 6 models. The administrator needs to do full CRUD on all of them. The next level down would be a regional manager that needs to do SOME CRUD on a subset (the team managers under him, plus the users under these team managers). The next level down would be team managers. They would need to do even less CRUD on their team members. The last level would be the team members. They would be able to CRUD some of their own record, but that's it.
Each team member is responsible for several zip codes. They need to be able to see their zip codes, and several businesses that are in those zip codes, but not edit anything. The team managers would need to see all of their team members, and re-assign zip codes throughout their team. They would also need to edit their team members records. Same for the regional managers, but they need to edit the team managers as well.
Here is where I start getting very confused. Each model has list, show, add, destroy and _form. Add them all up, and that's 30 views. That seems a bit, well, excessive. Is there any way to make the views dynamic, so there's only 5 views instead of 30?
I know it's semi-verboten to do application logic in the views, but then how do I make fields un-editable and downright hide other fields for certain roles?
I normally try to figure stuff out for myself, but I've been wrestling with these questions for 2 days now. Luckily, I'm not working with time constraints, and if I never finish it, no one's the wiser. But, I'd really like to finish it.
By the way, I'm experienced with database design, so my db is set up nicely, and I did figure out relationships in my models (my views work properly with foreign key fields rendering nicely). I also have Agile Web Development with Rails(2nd Ed.), Ruby for Rails, and the Rails Cookbook, but none of them give me a clear idea of how to proceed.
Sorry for the length, feel free to beat me up for details.