Monday, April 17th, 2006

Ajax in Rails Slides

Category: Prototype, Ruby

Thomas Fuchs has published his Ajax in Rails slides from the Canda on Rails showcase.

Once you download the PDF you can skip through to the RJS goodness that came in Rails 1.1.

In there you will see how you can just write Ruby, and the JS that gets generated. This is all based on Scriptaculous 1.6 and Prototype 1.5 that just came out.

Posted by Dion Almaer at 11:54 am
10 Comments

+++--
3.9 rating from 42 votes

10 Comments »

Comments feed TrackBack URI

After reading that pdf, why does it seem like Ruby is just as complex if not more so than just using JavaScript in the first place? Why not just learn JavaScript to begin with? JS is fairly universal, and very very powerful as i’m sure we know. Using Ruby to generate JavaScript seems like a solution in search of a problem. JavaScript is a standard, it is widely supported on all platforms that i know of, it works on the front-end and the back-end equally well – and if you realize the potential of this last statement, then you won’t need to learn 4 different languages to build a website.. just write code once and use it on the client or on the server. It isn’t like JavaScript is difficult. Ruby doesn’t look any easier to learn! Using a scripting language to generate a script in another language just seems redundant. Ahh, but I guess there are languages out there for as many personality types as there are programmers.

Comment by Damien — April 17, 2006

It’s completely redundant. If anything Ruby’s syntax is uglier than JS’s and JS enjoys more popularity. Maybe the philosophy is, if there’s one more knife in the infomercial, the buyer will be more tempted to buy.

It’s the last knife you’ll ever need! And you order now, you’ll get this free extra knife with no extra charge!

Comment by Ivan — April 17, 2006

It’s redundant plus. JS is really a pain to work with, compared to Ruby. People say JS is easy, but I think looking around at the status of apps done with it would show that it takes a lot of complicated code to accomplish much of anything.
It seems to me (because I learned JS through RJS), that the real value is in providing a path from Ruby to JS and vice versa. The only language browsers support is JS, and there is a real benefit in keeping as many conventions from a language you are comfortable with, to a language that you aren’t comfortable with.
I know JS, but I will always still hate it more than Ruby.

Comment by Barry — April 17, 2006

Barry, you hating JavaScript. Is that the reason you used Dreamweaver to develop your website ;-)

Comment by José Jeria — April 18, 2006

Ouch José… Burn….. ;)

But to continue with the real discussion.
There might not be that amazingly much simpler to do these things in RJS. But at least we are just using one language to develop the application. It just seems to me to be cleaner and minimizes the comlexity levels.

Comment by Jon Gretar — April 18, 2006

In all fairness, it’s hard to judge the complexity of an environment from a presentation given to what was likely to be a room full of Rails geeks.

Whether or not you think Ruby is uglier than Javascript or not, the idea here that the rendering layer (XHTML, CSS & Javascript) should be generated from the server side application rather than hand coded, is a good one.

Comment by dkappe — April 18, 2006

Seriously like rails itself if you want to see its power, try it.
I made an application with 1.0 and started to rewrite it with 1.1 and it really makes life easier, I don’t consider rjs as a replacement for javascript it just another tool in the awesome toolbox rails is.

When you want to do pure javascript just do it in a .js included file, if you want to mix ruby code and javascript do it in a rjs file.

Comment by Schmurfy — April 18, 2006

Like rails itself if you want to see its power, try it.
I made an application with 1.0 and started to rewrote it with 1.1 and it really makes life easier, I don’t consider rjs as a replacement for javascript it just another tool in the awesome toolbox rails is.

When you want to do pure javascript just do it in a .js included file, if you want to mix ruby code and javascript do it in a rjs file.

Comment by Schmurfy_ — April 18, 2006

The funny thing is, besides some minor syntactical differences, most of the RJS code translates directly to JS code. Just add some curly braces, change |foo| for function(foo){} and you are done :-)

Comment by Martin Bialasinski — April 20, 2006

Why Javascript?

The number one frequently asked question around Project Phobos is: Why JavaScript?

Trackback by Roberto Chinnici's Blog — May 24, 2006

Leave a comment

You must be logged in to post a comment.