I just got my first Rails 3.1 on JRuby project created. However I keep getting the error "Could not find a JavaScript runtime ..." when trying to do pretty much anything with it. After digging in to this some, it turns out that with the addition of CoffeeScript in 3.1, Rails needs to run Javascript code natively. A gem called execjs was added to Rails to allow this. EXCEPT, execjs itself needs something else to actually evaluate the Javascript. See
https://github.com/sstephenson/execjs for a list. If you're running in Mac or Windows, you're good, there are system libraries to do it. But if you're in Linux, unless you have node.js installed, it won't work.
Let me repeat that. Rails 3.1 apps by default will NOT work in Linux, unless you have node.js installed. This is absolutely ridiculous... guess what Rails team, a lot of people are developing in Linux and not Mac. I understand how stuff not working in Windows is released, but Linux??
So to get things to work you'll need to add one of the gems listed on the execjs page. If you're running the MRI Ruby, just add:
gem 'therubyracer'
to your Gemfile. I've read a lot of complaints about therubyracer. But it appears to be the most popular. If you're running JRuby like me, add:
gem 'therubyrhino'
to your Gemfile. I've verified that this works correctly.
FOLLOW UP 1/13/2012:
See my comments. I have made a fix to Rails to put the appropriate gem in the Gemfile if you are in Linux, and issued pull requests to the Rails core to incorporate this code. They have made some comments on it, hopefully it will be pulled in to Rails soon.