Fixed enough things to get assets to compile on master (don't merge this)

**Don't merge this!**

This is a patched up version of discourse to get all the specs passing with the latest Rails master. Some of the stuff I did are pretty hackish.. I'll submit a few smaller PRs in the next few days with better commit messages etc. But this is here for now if anyone wants to reference it!