An Editorial Based on the Original Article from 2007 - RJS Templates

How Has Ruby on Rails Changed Since 2007?

In this article we discuss the general sentiments expressed by the original author about the particular area of Rails, RJS Templates. The original article can be found on the Wayback Machine.

Under-utilised Features of RoR

The original article provided a comprehensive walkthrough on implementing RJS templates in Rails projects to simplify and enhance Ajax calls. It began by acknowledging that many features within the Rails community remain underutilized or not fully explored, particularly RJS templates, which were often overlooked by developers more familiar with other, more traditional methods.

Since 2007, the Rails community has continued to thrive, with more structured community outreach, documentation, and tutorials that aim to shine a light on lesser-known features.

The commitment to exploring and sharing knowledge about such features, as demonstrated in this article, has laid the groundwork for a culture of continuous learning and adaptation in the Rails community.

In fact, in the Stackoverflow 2023 Developer Survey, Ruby as aprogramming language of choice moved up one position in popularity.

The Rising Popularity of StimulusJS and Webpacker

The author stressed the inefficiency of cramming multiple Prototype/Scriptaculous calls into the `:update` property of a `link_to_remote` method, advocating instead for the use of RJS templates. To illustrate the power and simplicity of RJS, the article guided readers through setting up a new Rails project focusing on creating a blogging system that allows users to post entries, and others to comment on and rate these entries. This setup served as the backdrop for introducing RJS.

While RJS templates were a novel approach to simplifying Ajax calls within Rails applications, the Rails community has since embraced newer technologies such as Webpacker and StimulusJS, which offer more modern solutions for handling JavaScript in Rails applications. The spirit of innovation and willingness to embrace better tools, as advocated by the author, aligns perfectly with the Rails doctrine of making developers' lives easier.

Handling Database Migrations

The walkthrough covered the creation of models, controllers, and migrations for entries, comments, and ratings, intentionally skipping over users and permissions to keep the focus on RJS. It highlighted the importance of database migration scripts, likening them to the necessary but often disliked Brussels sprouts of Rails development.

Emphasis on Database Migrations: The author's emphasis on the importance of database migrations underscores a practice that remains a cornerstone of Rails development. The framework has continued to enhance its migration features, including adding support for complex database functions, demonstrating the enduring relevance of the author's advice.

Further into the tutorial, the author explained how to make controllers work with RJS by altering traditional `.rhtml` views to `.rjs`, emphasizing that this is the primary difference when opting for RJS in Ajax implementations. The RJS templates allow for direct manipulation of the DOM through the `page` object, enabling dynamic updates to the page without requiring a refresh.

The introduction of ActionCable in later versions of Rails provides a more integrated solution for real-time features within Rails applications, building on the foundational work of earlier features like RJS templates.

Examples included updating the comment count, displaying a notification message, inserting new comments into the page, and applying visual effects like highlighting and fading. These examples demonstrated the elegance and efficiency of using RJS templates over conventional methods.

Overall, the article served as a beginner-friendly introduction to RJS templates in Rails, showcasing their potential to streamline and enhance Ajax functionality in web applications. It shows that even though technology may move on, the passion of developers to find new ways to do things stays the same.