Dr Nic

Give up RJS and go pure

RJS seems like a nice idea. Its Ruby with embedded Javascript.

Now put away the crayons and get back to pure Javascript with embedded Ruby with “MinusR” – RJS minus the R (for Ruby).

This is especially useful if you want a clean way to support non-Prototype/Scriptaculous frameworks, like jQuery. You can call the raw Javascript for these libraries, and embed your Ruby objects using Erb and a handy js helper to convert Ruby to JSON.

Its clean, healthy fun. Like carrots.

Makes me think about jogging, its just that healthy for you.

Related posts:

  1. Autotesting Javascript in Rails I used to love Javascript so much that it would...
  2. Supporting JSON callbacks in Rails Now you know how to write JavaScript widgets, now you...
  3. Extend Prototype $() yourself If you’re using the prototype javascript library, its fun to...
  4. Ajax on Rails – Prototype vs JQuery [Original article published on DevLounge - please post comments there]...

8 Responses to “Give up RJS and go pure”

  1. Rodney says:

    Most of the time rjs just confuses me. This has my vote. Much directer/clearer.

  2. Dr Nic says:

    Yeah, I just found RJS was a 3rd programming language of sorts. I knew Ruby, I knew Javascript, and now I needed to know RJS. If you’ve got to look up the Prototype/Scriptaculous libraries anyway to know what you can do and want classes/methods to call, may as well express it in JS.

    I might change my mind in time, but I think I’ll use MinusR for awhile.

  3. zerohalo says:

    Is it possible to give an example?

  4. zerohalo says:

    Sorry, never mind, found it on Dan’s site.

  5. I very much agree. Hmmm should AjaxScaffold move to use MinusR instead or would that just be a maintenance nightmare?

  6. Dr Nic says:

    @richard – pragmatically – if its already working now, I don’t see significant benefits. Plus, for AjaxScaffold – a generator – there aren’t enough unit tests (last time I looked) to let you refactor with confidence.