Monday, September 17, 2012

Install pgAdmin for PostgreSQL 9.2 on Ubuntu 12.04


The Ubuntu 12.04 package manager will install pgadmin3 version 1.14 which does not support PostgreSQL 9.2.

Warning:
The server you are connecting to is not a version that is supported by this release of pgAdmin III.
pgAdmin III may not function as expected.
Supported server versions are 8.2 to 9.1.

Remove the current pgAdmin version


sudo apt-get remove pgadmin3


Install pgAdmin version 1.16 using a ppa


sudo apt-add-repository ppa:voronov84/andreyv
sudo apt-get update
sudo apt-get install pgadmin3


Update: If you are having trouble with the method above (see comments below) try the .deb install.

pgAdmin 1.16 (amd64)
pgAdmin 1.16 (i386)


Saturday, September 15, 2012

Replace PostgreSQL 9.1 with 9.2 in Ubuntu 12.04

Recently released PostgreSQL 9.2 comes with a heap of new features and improvements over 9.1.

These are the steps I took to remove 9.1 and install PostgreSQL 9.2 in Ubuntu 12.04.

Warning: This procedure is suitable for test and development environments only as it will wipe out all 9.1 databases


1. List currently installed postgres packages


sudo dpkg -l | grep postgres


2. Remove postgresql-9.1

*these packages were on my system

sudo apt-get --purge remove postgresql postgresql-9.1 postgresql-client-9.1 postgresql-client-common postgresql-common postgresql-doc postgresql-doc-9.1


3. Install postgresql-9.2 with official ppa


sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql-9.2

If you cannot add the repository
sudo: add-apt-repository: command not found

Install this package

sudo apt-get install python-software-properties


4. Check postgresql is set to the default port 5432


sudo netstat -lp | grep postgresql


5. Reset to default port if necessary


sudo gedit /etc/postgresql/9.2/main/postgresql.conf

port = 5432 *change the port value in the conf file

sudo /etc/init.d/postgresql reload


6. Setup your project database / user and database.yml


PostgreSQL Setup for Rails Development (skip to step 2)


Sunday, August 12, 2012

Could not find a JavaScript runtime

Devs new to Linux will hit a 'Could not find a JavaScript runtime' error when trying to start a rails server.

The reason for this is Linux, by default, does not have an interface to a JavaScript engine.

Use one of these methods to install the interface required:

  1. Add The Ruby Racer gem to your Gemfile assets group:

    group :assets do
      gem 'therubyracer'
    end

    * Its a bit of a memory hog (Heroku discourage it) and you need to add it to every project you spin up on that machine.


  2. Install the Node.js package to your machine:

    sudo apt-get install nodejs

    * Distro specific installation: Installing Node.js by Package Manager


Sunday, July 29, 2012

Learning Rails Testing with MiniTest:Spec instead of RSpec?

If you haven't already, or if you are just starting out with Rails, now would be a good time to take a look at MiniTest:

  • Included with Ruby 1.9
  • Likely to replace Test:Unit in Rails 4
  • Complete Suite (Unit, Spec, Mock, Benchmark)
  • Fast, readable, efficient

Any other Rails beginners skip through the RSpec tests in a two-footed lunge at Michael Hartl's Rails tutorial?

With the best of intentions I didn't stand a chance:

  • Prior experience - my non-Ruby testing consisted of basic manual logical steps
  • Frustration - tests take time and I came to the tutorial to learn Rails
  • RSpec's alien syntax - strange snake_cased semi English

As a Rails beginner this is what I needed to know about testing before taking the tutorial:

  • To write efficient and elegant code we need to check its quality and stability using a testing framework
  • Tests are the backbone of a Rails project giving confidence to change and improve
  • Would you accept code into your project that isn't tested?

A year on and wanting to improve my testing code and workflow I revisited the holy grail of Rails tutorials with the plan to use MiniTest:spec in place of RSpec.

No real issues so far and couple of nice workarounds here is my GitHub repo *work in progress

Helpful Resources

Please share any MiniTest resources you find and i'll update the list.