In all real world RoR projects I have worked or know about the view layer is used to render UI, no one is serving content. Most of them have complex UI screens with a lot of reusable elements that are present not only on different pages, but sometimes on the same page as well. With some of the elements(widgets) having their own JS behavior.
In all of the projects, I see the same problem - following the Rails abstractions just doesn’t work for this complex UIs, there is a lot of view logic in partials, a lot of random partials that are not part of any particular controller, because they are used everywhere, but still people have no idea where to put those. A lot of global space helpers. Some might have moved to the
Presenter concept, but they are still issues that most of those elements(widget) require JS to work properly, which is mostly done in very ad-hoc way.
One solution is to move to a complete client side framework to handle the UI part. What is interesting is that every client side framework use composition of objects to represent the UI, while almost every backend framework is stuck to the template abstraction. For me, it’s obvious that the template abstraction is not suitable for UI modeling at all.
I think one of the problems is lack of clear documentation of the limitation of such view system, what types of UI can be modeled, how to do partial AJAX updates, if possible at all, etc. What I see is a lot of inexperienced people grabbing the RoR templates and shooting themselves in the foot with ad-hoc partials and JS. So I think a good explanation of the limitations and possibilities with such system will improve the current situation a lot.
Maybe the future is in client side frameworks with ways to pre-render on the server, I don’t know. But maybe, it is worth considering more object oriented approaches like the Cells gem is trying and define a framework for connecting JS behavior with server side rendering while still keeping the processing logic mostly on the server, written in Ruby.
I think there is a huge lack of clear architectural understanding of the view(UI) layers in the community in general, and even a good documentation on the subject will help tremendously.
I’m starting this discussion to see what Lotus developers think on the subject.