
Rails 3.1 has jQuery by default - vijaydev
http://weblog.rubyonrails.org/2011/4/21/jquery-new-default
======
rsbrown
Finally. As "opinionated software", the success of Rails depends on neatly
slotting into the well-worn groove of best practices adopted by its user base.
Like it or not, jQuery has filled that role nicely for client-side javascript
for quite a while now.

~~~
bradly
Rails is opinionated software, but it isn't the opinions of its userbase; It
is the opinions of DHH. If DHH/37 Signals isn't using it, it probably isn't
going to make in to Rails core. I am not saying that this is a bad thing.
Having the defaults based on a profitable, stable web app with millions of
users isn't the worst idea.

~~~
bonzoesc
> If DHH/37 Signals isn't using it, it probably isn't going to make in to
> Rails core. I am not saying that this is a bad thing.

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...](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/array/access.rb#L42-L45)

~~~
troutwine
That was introduced by this guy: <https://github.com/jeremy>

Don't know that I understand what he means by accessing "the reddit", though.

~~~
FooBarWidget
A while ago a 15-20 line patch was committed, which added the methods
Array#second, Array#third, etc. These methods were added as syntactic sugar,
in order to complement the built-in Array#first. What followed was a huge
uproar on Reddit; people called the patch "bloat", claimed that Rails is
growing into an uncontrollably large monster, etc. The uproar was not unlike
the recent uproar about Coffeescript in size. DHH made fun of that by adding
Array#forty_two.

------
JangoSteve
If anyone is curious, the default accepts header in jQuery is

    
    
        */*
    

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."

~~~
euroclydon
This isn't clear. Are you talking about the default accepts header in a jQuery
AJAX request or in some jQuery script loader script that rails uses to load
the jQuery library?

~~~
JangoSteve
Sorry, I was talking about the default accepts header for jQuery AJAX
requests.

------
clu3
I'm not a RoR boy, but sometimes watch RoR screencasts to pick out good
points. Really surprised that RoR was using its own JS library and has not
adopted any other dedicated js lib out there Drupal for example, initially had
its own js lib, but then adopted jQuery officially many years ago

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

~~~
ryanbrunner
Rails doesn't have it's own JS library. It initially used only the prototype
library (which exists outside of Rails), but with Rails 3 any javascript
supplied by Rails was made library agnostic.

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.

~~~
vijaydev
DHH had already made it clear that RSpec will not get into Rails.

------
cygwin98
I recall there was a post a week ago saying that Rails 3.1 will go with
CoffeeScript. Maybe they received lots of negative feedback on that shot, so
they fall back to plan B.

~~~
5l
No, CoffeeScript and jQuery will both be defaults in Rails 3.1

