Search code examples
javascriptruby-on-railsrjs

What defines RJS? confused with what I have Read


I am a little confused from what I have read on stackoverflow regarding RJS.

Many people have stated that Rails 3.0 has dropped RJS for UJS .This statement confuses me because from what I understand the difference between obtrusive (inline) and unobtrusive JavaScript doesn't define RJS itself.

Isnt RJS the act of using JavaScript templates and having AJAX calls return code which is in turn executed at the clients end, as opposed to the non-RJS route of having the app return JSON or XML, i.e. just the data, and having the client side JavaScript deal with it?

If what I have said is correct Rails 3.0 does support RJS and you can use UJS with RJS, although I believe support in 3.1 will be separated into optional gem(s).

Example:- UJS used with index.erb and in application.js but data is returned in index.js.erb therefore UJS is used with RJS


Solution

  • You're right, it's sometimes confusing. My point of view is that:

    • UJS appeared with Rails 3

    • RJS will be extracted as a gem in Rails 3.1

    • UJS and RJS only have JS in common