I was recently playing around with Juggernaut, which is a very useful Rails plugin. If you’re building applications where the server needs to push data to clients then Juggernaut is worth a look. Under the hood it basically uses a Flash shim to open a persistent connection with the server and then events can be broadcasted from the server to all connected clients. This can be useful in chat applications and anything where near realtime collaboration is useful.
To install Juggernaut the JSON library is necessary. I tried installing the JSON gem by issuing the following command: gem install json. In doing so I received the following error message:
Successfully installed json-0.4.1
Installing documentation for json-0.4.1…
lib/json/editor.rb:977:50: ‘:’ not followed by identified…
Installing RDoc documentation for json-0.4.1…
lib/json/editor.rb:977:50: ‘:’ not followed by identified…
While it looked like JSON was successfully installed I came to find out that it wasn’t when I tried to start the Ruby push server: ruby script/push_server. You can see the details of the Juggernaut install here if you’re interested. After trying to install the gem a few more times I was ready to give up and move on. Luckily I decided to try a manual install and see if my results were any different. I opened a command prompt (on XP) and navigated to the JSON gem directory: C:\ruby\lib\ruby\gems\1.8\gems\json-0.4.1. In this directory was a file named install.rb so I issued the following command: ruby install.rb. This yielded the following output:
cd bin
install -c edit_json.rb C:/Ruby/bin
cd -
cd lib
install -c json.rb C:/Ruby/lib/ruby/site_ruby/1.8
mkdir -p C:/Ruby/lib/ruby/site_ruby/1.8/json
install -c json/editor.rb C:/Ruby/lib/ruby/site_ruby/1.8/json
install -c json/json.xpm C:/Ruby/lib/ruby/site_ruby/1.8/json
After this I decided to give the ole push server another go and it booted right up. I was able to run Juggernaut and successfully push data to multiple clients. I’m excited to see where this project will head and this definitely lends well to the whole Comet initiative.
Was stuck on the same issue. After much hairpulling i just ended up copying json.rb to my rails root folder, but your solution is better. I learnt a bit tracing through Juggernaughts code trying to find the issue. In this early version, it doesnt seem very robust yet, but its small, easy to modify, and a great idea.