I have worked on two projects using Ajax and Ruby. In one project, I used Rails Prototype helpers and RJS. In the other project I used HAML and unobtrusive Javascript with jQuery. Each had a learning curve which I have overcome. However, the long-term costs and benefits of either approach are not clear. For my next project I am trying to decide between:
- Rails + HAML + jRails + jQuery
- Rails + HAML + unobtrusive jQuery
The trend in Rails, especially Rails 3.0, seems to be towards using unobtrusive Javascript, but it is not clear to me why this is better, especially when you get so many useful helpers (such as remote_form_for) from Rails/jRails. In trying to make this decision, I have the following questions:
- Which approach leads to less code to achieve the same amount of functionality?
- Which approach is less error-prone?
- Which approach is easier to test?
- Which approach is easier to read, maintain, and evolve?
- Which approach lets you more easily degrade your web application gracefully (by providing the same functionality without Ajax) when Javascript is disabled in the client browser?
I appreciate any help or insight you can provide.