Adding Postgres and ActiveRecord
Getting started - adding dependencies to your project
Adding a Gem to your project is pretty simple. You just need to do three things:
Add a line that includes the Gem in your gemset (or gems that are included as requirements for your project to work)
Once, you’ve added a new line, save the changes
Then in the command line (Terminal on OSX or Command Prompt on Windows), update your gemset by typing
You should see the Gem you just added listed as an addition to the project (highlighted in green)
In your code file (
app.rb), you need to tell the project to include the functionality of the gem. We do this by adding a line at the top of the code file.
It’s important this appears right at the top of the codefile, so that the server includes this functionality right as it launches.
This is the workflow for almost all Gems.
You should check the documentation for any gem you want to use in your project. Some of the gems you want to work with may have additional steps like adding some configuration information (e.g. additional instructions on how the gem is used or setup with the code). Most of the developers who share gems will take the time to share these instructions in the
README file of their code repository. Take a look there before you use any gem to know what’s involved.