I'm new to Rails 3.1 and recently started a project. My Gemfile contains jquery-rails like so:
gem 'jquery-rails'
And indeed, I have verified that it's present (version 1.0.19) in my current RVM gemset (using gem list
).
I started to get into Ajax-enabled forms, and from reading various articles and posts from Googling, it appears that I'm supposed to have a file called rails.js
in my javascripts
folder (I assume this is assets/javascripts/
, and I am using the default asset pipeline).
My question actually involves two parts:
I couldn't find a
rails.js
file in my project even afterbundle install
, so I downloaded it from https://github.com/rails/jquery-ujs and placed it in myassets/javascripts/
folder. Is this the correct thing to do?Upon including
rails.js
, my Ajax form now submits three times. Upon further investigation it appears as if all my javascript (or jquery???) is getting called three times. When I click on the "destroy" link for an object (the kind generated when yourails g scaffold something
), the confirmation pop-up comes up three times as well. Removing therails.js
file also removes this issue.
Any help or advice will be greatly appreciated... I've been searching around Google and SO for hours, and haven't gotten anywhere. Thanks!