rubyforgood / applied-conservation

MIT License
7 stars 17 forks source link

Setup Devise and DB on local machine #109

Open efl7a opened 6 years ago

efl7a commented 6 years ago

Hello RubyforGood team, I forked and set up the website on my local machine so that I could contribute as part of Hacktoberfest. It was only my second time working with Postgres and it took quite a while for me to figure out what I needed to add to get it up and running. If you are interested, I can add this information to the Readme to make it easier for future contributors.

Just for my own edification, is there an easier way to deal with the issues of devise master key and postgres username and password? I added and then deleted those bits of code every time I made a commit.

juliegoat commented 6 years ago

I had some issues with this too, and would be happy to help with documentation as well :)

jgaskins commented 6 years ago

First of all, we really appreciate your help so far and we're happy that you're participating in Hacktoberfest!

These are great questions. Looks like Devise barfed because its secret key defaults to the Rails secret key base, which is stored in the credentials file, which is encrypted, so it was the same as if a secret key wasn't set. We don't store the encryption key in the repo, but other than the Rails secret key base, we don't truly need anything in that file, so we really only need to be able to get that key base. I added some instructions to the readme to let you generate it.

Getting this to work without my own master key and the credentials file was a mess that involved a bunch of trial and error and ultimately required a Devise upgrade — Devise needed the file, but Rails loads Devise before it gets there, so we needed a version of Devise that took this into account before barfing. I apologize, we did realize back when we were first getting setup that this was a problem but we worked around it by just passing the master key out to team members … and then promptly forgot about this new feature of Rails so we never solved the onboarding process for real. I'm really sorry about that.

When it comes to Postgres, the default user depends on your OS, I believe. Usually there'll be a postgres user or one setup for your system user account — I think with Mac OS (either Homebrew or Postgres.app) it creates one with your system username and for Linux it creates a postgres user. I think createuser -s the_expected_username will get it working locally. Just make sure you substitute the whichever username Rails and/or Postgres appears to be expecting (it calls it something weird instead of username — role, maybe?) in place of the_expected_username. :-) It's possible that running on other platforms like Cloud9 might require other handling, but I'm happy to help out there, as well.