6 ms·
Rails 3.1 has jQuery by default
- rsbrown 15y agoFinally. 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 15y agoRails 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 15y ago> 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/active_support/core_ext/array/access.rb#L42-L45 https://github.com/rails/rails/blob/master/activesupport/lib...
- troutwine 15y agoThat was introduced by this guy: https://github.com/jeremy https://github.com/jeremy Don't know that I understand what he means by accessing "the reddit", though.
- deleted 15y ago[deleted]
- carbon8 15y agoIt was added as a joke in response to the controversy on reddit about the original commit.
- FooBarWidget 15y agoA 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.
- dimmuborgir 15y agoSo before every Rails release DHH should conduct a public poll? And what level of abstraction it should be? "Which JS framework should be made default" or "Should we have a default JS framework"? As you can see, it quickly becomes a mess. Opinions bring sanity.
- bradly 15y agoI think you may have misread my comment. I was saying that it isn't necessarily a bad thing.
- clu3 15y agoI'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 15y agoRails 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 15y agoDHH had already made it clear that RSpec will not get into Rails.
- deleted 15y ago[deleted]
- philcrissman 15y agoRspec doesn't really need to be in the default stack; switching to it takes what; a minute? That's not a benchmarked timestamp, but I'm just saying... :-)
- JonnieCache 15y agoPrototype was never "rails' own" js library. It existed before rails AFAIK.
- JangoSteve 15y agoIf 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 15y agoThis 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 15y agoSorry, I was talking about the default accepts header for jQuery AJAX requests.
- r00fus 15y agoI guess this makes sense if you're standardized on JSON (as opposed to say XML or HTML) responses.
- JangoSteve 15y agoKeep in mind that you can specify whatever data type you want with jQuery. The default I speak of is just for when you don't specify any data type.
- cygwin98 15y agoI 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.
- tomstuart 15y agoUnrelated. CoffeeScript is a language which compiles down to JavaScript; jQuery is a JavaScript library.
- 5l 15y agoNo, CoffeeScript and jQuery will both be defaults in Rails 3.1
- deleted 15y ago[deleted]
- ScotterC 15y agoUnrelated as commented by others but glad you brought it up for anyone else that was confused.
- cygwin98 15y agoMaybe I misunderstood the situation here. I thought the adoption of CoffeeScript is more like going the GWT way (not quite, but similar) --- you write code in CoffeeScript and let it generate all vanilla Javascript code doing the frontend work, e.g., communicating with the server, DOM manipulation. I do personally think that's a good approach. Now, you also have jQuery in the toolkit, which I suppose is used for DOM manipulation, that's another tool to learn. If you guys just replace Prototype with jQuery, it is reasonable, or just CoffeeScript, which is radical, but sounds like a neat approach. However, CoffeeScript + jQuery? I just don't think it make sense here. Honestly, I only have superficial knowledge of CoffeeScript and jQuery, I could be totally wrong. Maybe somebody in the Rails core team should write a blog to clarify their strategy on their Javascript integration.