开发者

Rails App with Multiple Namespaces

I'm getting started on a large Rails project that will consist of several independent areas including and admin area, front-end website, user area, and api.

Would it be wise to create say, 3 na开发者_JAVA技巧mespaces for these sections (leaving the front-end website as the root)?

There doesn't seem to be a general rule regarding namespaces and it seems like the right choice for organizational purposes since each area would require several controllers.

In my past Rails projects I always namespace the admin, but in this case, are there any drawbacks to having multiple namespaces in the long run (in regards to routing / interacting with other namespaces)?

Any advice would be much appreciated!


no drawbacks only advantages if the namespaces make sense. Obviously having too many namespaces might be confusing and pointless but breaking up admin/client/public is a pretty common use case for using namespaces.

just make sure you give all your controllers unique names, so you don't run into the problem this guy ran into with namespaces: http://blog.philburrows.com/articles/2008/05/02/rails-namespaces-rock-rails-namespaces-suck-/


If your project really does consist of logically independent areas then I don't see a downside. Any routing situation can be implemented with minimal effort, so that's not a dealbreaker.

One think you will have to keep in mind is that your project is going to have one extra level of directory nesting. For example, you can't just look in the views directory and get a good idea of all of your views, because they will all live in directories corresponding to their namespace (the same goes for tests). This is often desired, however, as it helps things stay a little more organized.


checkout http://www.ror-e.com and the github app https://github.com/drhenner/ror_ecommerce It has several namespaces and most namespaces have their own base_controller.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜