[Rails] Controllers and Namespaces (no problem, just questions)
Andrew Stone
stonelists at gmail.com
Fri Sep 1 14:34:19 GMT 2006
I'm a little late on finding this article:
http://habtm.com/articles/2006/07/01/if-your-models-arent-namespaced-why-should-your-controllers-be-or-how-i-learned-to-stop-worrying-and-love-the-crud
This idea does not sit well with me and am curious as to the Rails roadmap.
I've seen a couple things demonstrated in examples (Rails Book, api) that
later turn to become deprecated. As others have suggested, a resource for
features/methodologies that are or will be deprecated would be a very nice
addition.
I personally don't agree with the current authorization examples (plugins,
examples, etc..) I've seen and have written my own. Namespacing the
controllers is an integral part of my authorization code. It allows me to
easily group system functions and quickly check for access rights based on
the namespace. There is no code that is peppered throughout my controllers
to allow/deny access, but a single "secure controller" that checks the
request and checks it against an array of allowed controller/actions. By
default, everything is locked down unless I open it up. Being that my
system is database centric, I can also manage rights via a couple of
management screens without changing any code.
I like my way and am getting the uneasy feeling that there is a growing
anti-namespacing controller sentiment which could lead to discontinued
support. If namespaces break plugins, then I say fix the plugins. Just
become some plugins don't work well with namespaces I don't think it's fair
to throw out a new mantra stating namespaces are bad.
For the following statement: "if your models aren't namespaced , why should
your controllers be?", well I respond by saying models don't contain
business logic, controllers do. The duty of the model is to simply provide
CRUD methods to your database. Controllers utilize these models to provide
functionality as the business requires.
I don't find myself violating the DRY principle with this approach, I use
partials and lib files to keep it that way. In fact, putting some
functionality into the lib directory has made it easy for me to utilize the
same code in multiple projects.
I would like to see what my fellow railers think of namespacing controllers
and would also like to hear from some of the rails developers to see if this
is really a problem or am I just being paranoid.
thanks,
andy
--
Andrew Stone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060901/bc5d4532/attachment.html
More information about the Rails
mailing list