Postgres (or PostgreSQL) is an open source database. Ruby on Rails is an open source web framework written in Ruby. Rails is database agnostic, meaning it can be used with a variety of different databases. By default it assumes that MySQL is being used, but it's quite easy to use with Postgres instead.
This guide will step you through creating a Rails application that uses a Postgres database. You can follow the guide on your local machine or a VPS.