Fixed a little bug (added check for nil)

After switching from Unicorn to Passenger i found my AJAX won't work. Clever people advised me to check logs, and i found this little bug and made pull request :-)