Monday, December 7, 2015

How to run Rails with PostgreSQL on openSUSE Leap 42.1

I wrote about how to run Rails with PostgreSQL on openSUSE 12.3 before. Things have changed since then. While Rails, PostgreSQL, and openSUSE are still excellent choices, new versions have been released. This warrants an update. So here is how to get a development environment of Rails with PostgreSQL running on the latest and greatest openSUSE Leap 42.1.

Install PostgreSQL:

    sudo zypper install postgresql-server postgresql-devel

Start the database server:

    sudo systemctl start postgresql

Enable server to be started on boot:

    sudo systemctl enable postgresql

Switch to the postgres user to set up the database:

    sudo su -l postgres

Create database user:

   createuser -d USERNAME

Return to your normal user, exchange the database driver in the Gemfile from sqlite3 to pg and run

   bundle install

Change the configuration of the database driver to something like:
  default: &default
    adapter: postgresql
    username: cs

  development:
    <<: *default
    database: APPNAME_development

  test:
    <<: *default
    database: APPNAME_test

  production:
    <<: *default
    database: APPNAME_production
Create the databases:

    rake db:create
    rake db:migrate
    rake db:migrate RAILS_ENV=test

That's it.

3 comments:

  1. That's nice but I still wonder why it's so hard to setup RoR on a production server like apache or nginx using passenger. A ready to use SuSE studio appliance would be great :)

    ReplyDelete
    Replies
    1. What exactly do you find hard there? There should be packages for everything you need, and configuration will vary depending on what your application does.

      An appliance would be great as a start. For a real production setup you will need more, though, so the application can be made scalable and highly available.

      Delete

Team Profile

What makes a great team? One important factor is that you have a balanced set of skills and personalities in the team. A team which only con...