Rails 3.1 has jQuery by default
weblog.rubyonrails.org
weblog.rubyonrails.org
That jQuery made it into Rails shows that it's not just DHH's app skeleton anymore; it remains to be seen if ActiveSupport will ever quit being DHH's junk drawer[1] though.
[1]: https://github.com/rails/rails/blob/master/activesupport/lib...
Don't know that I understand what he means by accessing "the reddit", though.
*/*
which means, "give me whatever you have." This will actually cause Rails to respond with whatever the first format is that you happen to have defined with your respond_to or respond_with method in your controller.This isn't very intuitive, which is why we made the jquery-ujs set the default accepts header for remote requests to
*/*;q=0.5,text/script
which says, "give me whatever you have but I prefer JavaScript if you have it."Edited: I must have misunderstood the RJS's purpose. Thought it was a JS lib, but it's not, it's just a way to generate JS code. And so i learned RoR's been using prototype. Sorry RoR fans, my bad
Prototype is a stand alone library and predates jQuery by almost two years. jQuery is more or less a direct descendent of Prototype and reimplemented all it's features with a slight twist to emphasis method chaining which was a key insight that simplified everything.
Prototype might actually be a tad bit older than jQuery even and it tries hard at "rubyfying" JavaScript. Because it does so by happily extending built-in prototypes and because it's a huge amount of monolithic code, over the years, people began moving to jQuery.
And now, finally, Rails is moving too.
Also note that with Rails 3.0, they began using data-* attributes for the framework-provided JS-dependent logic, so it became possible to easily replace the built-in prototype with jQuery. For 3.1, they are just switching the default.
RJS is a rails specific thing, but it's more a method of generating javascript inside of rails than a JS library in it's own right.
This change simply changes the default from Prototype to JQuery - a long-overdue change IMO, since the vast majority of the Rails community has been using solely JQuery for quite a long while now.
Here's hoping that the same treatment is done to RSpec vs. TestUnit.
Maybe somebody in the Rails core team should write a blog to clarify their strategy on their Javascript integration.
For reference: http://jashkenas.github.com/coffee-script/
CoffeeScript is much like HAML or SASS, where the end result is actual Javascript that can be parsed by the browser. It's only designed to make it easier to write the code, not to replace the code. When I write HAML in my Rails app, the app parses it and send the browser actual HTML. CS will do the same.
You can also use Javascript and jQuery directly.
Or you can write CoffeeScript without using jQuery at all.