How do I add jquery-ui to a Ruby on Rails 3.1 app? How do I add jquery-ui to a Ruby on Rails 3.1 app? ruby-on-rails ruby-on-rails

How do I add jquery-ui to a Ruby on Rails 3.1 app?


Perhaps it's easier to use the jquery-ui-rails gem (see announcement). It packages everything up so things "just work".


You can use google CDN, to add the css theme inside the head section of your app. Simply add this application.html.haml under the %head section(or the same thing translated to erb).

The css theme

%link{:href => "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/themes/ui-lightness/jquery-ui.css", :rel => "stylesheet", :type => "text/css"}

If you want the jquery-ui minified.

%script{:src => "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/jquery-ui.min.js"}


if you include 'jquery-rails' in Gemfile jquery-ui will be included requiring this in application.js:

//= require jquery-ui.min

if you run in Console: Rails.application.config.assets.paths you will get all paths Rails will look into for assets. In my case for instance:

- /Users/aldo/Satio/Desarrollo/rails/subaquaclub/app/assets/images- /Users/aldo/Satio/Desarrollo/rails/subaquaclub/app/assets/javascripts- /Users/aldo/Satio/Desarrollo/rails/subaquaclub/app/assets/stylesheets- /Users/aldo/Satio/Desarrollo/rails/subaquaclub/vendor/assets/javascripts- /Users/aldo/Satio/Desarrollo/rails/subaquaclub/vendor/assets/stylesheets- /Users/aldo/.rvm/gems/ruby-1.9.2-p290@subaquaclub31/gems/jquery-rails-1.0.13/vendor/assets/javascripts

See the last line ? if you check in there you will find jquery-ui so there you go.