jquery in rails, basically because I’m not sure where to put things in
I know the people at rails have thought long and hard about how to best
structure an app, so I’d like to learn the correct way.
I’m using rails 3.2, ruby 1.9.3
By default now I notice this is included in the gemfile : gem
there’s also these lines in application.js
//= require jquery
//= require jquery_ujs
and there’s this in my layout view
do I have to do anything at all to use jQuery in my application?
If I want to use some jQuery on a page, where’s the place to put it? in
the controller.js.coffee? Or on the page between
can I use js / jquery in this strange .coffee file?
2nd situation - now I want to use JQUery-UI
What is the best way to use jQuery UI, and where should I put it.
I downloaded the minimised version from jQuery website, but which folder
do I put it in? public/…?
What am I meant to add to application.js?
and do I need to add anything extra to the layout?
3rd Situation - now I want to use the jQuery-ui CSS to make it look nice
Do I link to the online page at
in my layout, pulling in the css dynamically
or copy and paste that to a file and include it in the project?
if I include this in the project where do I put it?
Do I need to add anything to application.css, and or my layout?
That’s enough for now! I know these questions might seem a bit
pointless, but I want to know the right way to do this. I had an app
looking and functioning perfectly on my local system, but then when I
uploaded it to heroku all jquery-ui stuff and some of the css didn’t
work, even after a ‘rake assets:precompile’ I’ve now got a project with
lots of extra includes, and js / css files repeated in different places
just to get it to work on heroku.
Very annoying, and I’m sure if I just knew the right way to organise
everything it’d be much easier.