Ruby on Rails + JQuery
English translation is below
Quando comecei a utilizar Ruby on Rails uma das primeiras coisas que eu procurei saber foi como substituir o Prototype e Script.aculo.us que são as libs padrão para utilizar javascript pelo JQuery.
Decidi fazer isso não pelo fato de achar o Prototype e Script.aculo.us ruins mas, pelo fato de a muito tempo eu já utilizar o JQuery nas aplicações web que desenvolvo e com isso ter uma boa experiência com ele e também por gostar muito deste framework javascript.
O Rails possui diversos helpers que tornam o desenvolvimento com ajax muito simples, porém, todos os helpers utilizam o framework prototype em conjunto com scrip.taculo.us e aí que entra um plugin que me poupou muito trabalho pois ele já faz a integração do JQuery com os helpers do Ruby on Rails ou seja, a mudança é feita de uma maneira tão transparente que até assusta :) pois normalmente este tipo de coisa não são tão simples.
Bem, para instalar o plugin basta executar o seguinte comando de dentro do diretório da sua app rails:
script/plugin install git://github.com/aaronchi/jrails.git
A partir deste momento sua aplicação já está integrada com o JQuery e os helpers passarão a utilizar o JQuery em vez de Prototype e para componentes de UI serão utilizados os componentes do JQuery UI.
Para importar todos os arquivos JS relacionados ao JQuery e aos helpers para sua aplicação, faça isso:
<%= javascript_include_tag :defaults %>
Você pode obter maiores informações neste site.
In English
When I started using Ruby on Rails one of the first things I wanted to know was how to replace the Prototype and Script.aculo.us libs because it is the standard for javascript and ajax to JQuery.
I decided to do this not because i think the Prototype and Script.aculo.us are poor, bad or something but because of the long time i'm already using JQuery in web applications and have a good experience with it and also really like this javascript framework.
Rails has many helpers that make developing with Ajax very simple, however, all helpers are using the prototype framework in conjunction with scrip.taculo.us by default and at this point i knew a plugin that has saved me a lot of work because he makes the integration of jQuery helpers with Ruby on Rails, the change was so clear that it really scared me :) because usually this kind of changes is not so simple.
Well, to install the plugin simply run the following command from within the directory of your rails app:
script/plugin install git://github.com/aaronchi/jrails.git
From this moment your application is already integrated with JQuery and all helpers will use JQuery instead of Prototype and UI components will use JQuery UI components.
To import all JQuery and Helpers Javascripts into your app justo do it:
<%= javascript_include_tag :defaults %>
You can get more info here.




