views:

210

answers:

2

What is the present state of Rails Ajax? What frameworks and technologies should one use when working with Rails now? Rails seems to evolve so rapidly that one might not be able to keep up. Is it prototype and RJS or something else?

+2  A: 

The point of RJS is that you don't really need to keep up with a framework, that the javascript functions are abstracted into Ruby for you to use.

That said, prototype is still the default choice, but there are plugins (http://ennerchi.com/projects/jrails) to implement RJS functions in jQuery. Of course, you could forgo the abstractions entirely and write the javascript however you'd like.

Personally, I find myself trying to stick to the Rails' default methods, and if I need a method that goes outside what RJS provides, making sure I am implementing it properly (ie. not duplicating what someone else has done), and usually doing it in prototype as to not have to load multiple javascript frameworks.

Dan McNevin
A: 

As said before, Rails' default javascript library is (and will probably always be) Prototype/Scriptaculous. However, when Rails 3.0 is released sometime around the beginning of May, it should be more accepting of other libraries such as jQuery.

If you don't like RJS, you can use a .js.erb extension and write javascript that will be sent through the erb template engine. This is my preferred way of doing things these days. You can see an example of this, and jQuery in this episode of Railscasts.

erik