Partial rails 3 compatibility

Not everything works yet (especially AJAX calls), but some are already fixed.