Recently i’m working on a project when i have more than just admin and
normal users, and all the work was made with single controllers for all
features. I use some very usefull techniques, that i will apreciate
criticisms. On this project, not just verbs is allowed/denied, but data
change following the user role.
First, i use before_filters to make access control, based on roles,
tools
categories and functions (at now it’s just C-R-U-D). A migration
categorize
all actions on the system (a biggest work, walking through controllers
path
and identifying true actions…). ACL was made across relationship
between
roles, functions and tool’s categories, all category have their own
function (CRUD again). The simple exclusion of verbs not work how was
spoken
on first email in this tread because links and other things will still
pointing to actions a errors will be raised.
To fix this problems, i just write a smallest plugin, that overwrite
link_to*** helpers, returning “” if the user has no access to the
specific
functionality.
To test this access restrictions i add useful methods like canCreate? or
canUpdate? to user model.
The biggest problem was change all data on the system based on the
roles,
because the logic behind the scenes was very deeply: some roles has
hierarchically restrictions, other roles has no restrictions, etc…
Add to this scenario, the fact that the system need information’s
filters
(the user select specific parent data, and all tree of data bellow this
parent data will be restricted to)!
… for this purpose i work with around_filters and with_scope… An
ugly
but usefull code that wraps all the application data.
I speak all this things because i think that this problem is not so
restrict
to anti-DRY pattern, or this isn’t about REST in self.
Keep your code clean on real applications that have real roles
relationships
is very difficult, and sincerely i think that REST is not so useful on
this
case. I am not speaking against use REST (i really understand how REST
can
help us)… The fact is that REST or no REST, the problem was the same
and
restriction REST based will not help you.
P.S.: just think about edit action! This is called through GET action,
but
users that can’t update, should not access this action…
On Dec 27, 2007 3:43 PM, Nathan E.
[email protected]
wrote:
anyway, I learned a lot about rails 2 with those two posts! thank you!
R�ben
–
Posted via http://www.ruby-forum.com/.
–
Everton J. Carpes
Mobile: +55 53 9129.4593
MSN: [email protected]
UIN: 343716195
Jabber: [email protected]
“If art interprets our dreams, the computer executes them in the guise
of
programs!” - Alan J. Perlis