First of all you need to install PostgreSQL:
sudo zypper install postgresql92-server postgresql92-develThis installs the latest available version. The devel package is needed to build the Rails drivers.
Then start the database server:
sudo /usr/sbin/rcpostgresql startIf you want to automatically start the server on boot enable the service with:
sudo chkconfig -a postgresqlTo finalize the setup of the database server you need to create a user, which Rails uses to access the database. You can choose whatever username you like, but the setup is most simple, if you use the username of the user under which you do your Rails development. The -d option allows the user to create databases, so the corresponding rake tasks can do their job.
sudo sudo -u postgres createuser -d USERNAME
sudo sudo -u postgres psql
By querying the users table you can check the existing users and their rights on the PostgreSQL console:
SELECT * FROM pg_user;
To connect Rails to the database, you need to create the database configuration in Rails. Create a file config/database.yml with something like the following content. You need to replace USERNAME
username: USERNAMEThen finally you need to create the databases with:
rake db:createand create the database tables by running the migrations of your Rails app:
rake db:migrateThat's all. Now your Rails app runs on PostgreSQL, and you can do all your development and testing as usual.