-
Notifications
You must be signed in to change notification settings - Fork 2
Notes: Rails
Problem: One file that was blacklisted in my .gitignore by default was config/initializers/secret_token.rb
. Although it is pretty obvious why this file was placed in .gitignore, it was causing issues with deployment to other machines (we had to manually copy and paste the file into each new workspace).
Solution: By using the dotenv gem, we are able to manage the secret key through environment variables. When using Heroku, be sure to set the configuration variable through Heroku with heroku config:set SECRET_TOKEN=[insert token here]
Problem: I kept on encountering an error where the function stringify_keys
was undefined no matter what I tried.
Solution: It turns out that it was because my variable name was called attributes
, which is a no-no when working with ActiveRecord. I changed it to attrs
via migrations and the problem was resolved.
Problem: I couldn't figure out how to use foreman
to sync environment variables (were not loading correctly, foreman would not start for some reason)
Solution: A temporary workaround is to simply add the variables through your ~/.bashrc
file so it will be loaded every time you start Terminal. This is suboptimal for obvious reasons though.
Problem: The command rake db:reset
claims that it cannot read or write to the database.
Solution: Rename the file .env
in your application directory to .env.old
. This is a temporary fix.