Troubleshooting postgresql in rails
Note to Reader: I hope this post helps you or another code newbie get started with postgreSQL in rails. Also, don’t forget to laugh at your mistakes along the way.
As a lover of all things mobile… both UI and dev, I’ve decided to revisit Ruby on Rails.
Incase you’re unfamiliar with my background, I went to a coding bootcamp that focused on Ruby on Rails and have not looked at it since... Time to change that!
So after a couple days of refreshing myself on the foundation I was excited to build a web app, pronto! …but it did not quite happen as fast as I hoped.
Not only did I have to spend 30 minutes setting up iterm and git on my new MacBook Pro, I received a lot of errors in my terminal too. Perhaps caused by forgetting steps while installing everything again? Or maybe it was from trying a different aspect of Rails that I’ve never considered before: Postgresql.
After cd-ing and creating a new rails application, I included -database:Postgresql.
That is not something I learned at Tech Talent South because my cohort learned sql lite and the whole purpose is to to avoid just that.
When you do not set up your database in a web app using postgresql, the application will use sqlite by default. Using PostgreSQL is very common in production applications using rails because the database will be incorporated in the local machine as well. The benefit of using the same database in both local and production machines is that there’s less hassle with licensing, custom data types, table inheritance, and most importantly you’ll avoid database errors. At least, that’s my understanding so far!
Okay so cool. Yeah. Let’s do this.
No wait, another problem.
I’ll be honest… at 1am, I was pretty slow. I reinstalled homebrew. Not helping. So I did a bundle install. Not helping. Then reinstalled some gems. Also, not helping.
Finally, it occurred to me that I was WAY OFF. Those things have nothing to do with the server. Duh. So naturally, I asked my friend Mr. Google who naturally directed me to the wonderful people at StackOverflow. I found the solution in this post which recommended:
And it worked! When you copy and paste the above in the terminal, it manually starts the server.
If this isn’t working for you, don’t worry! There’s also another possible solution:
Before I learned this, I messed around with home brew earlier so I’m keeping this in my back pocket incase I truly screwed things up. But the only way to find out is to… well, wait and find out.
Thanks for reading!