2

Just trying to set up rails app on ubuntu to do some low level dev work without going through the hassle of bothering our main devs. However at the very end of the process, I run rails s command. I get landing page on localhost:3000 and can get through the pages without direct call to database. However when I go to any page that gets the data from db, it gives me following error:

 ActiveRecord::StatementInvalid in WantsController#new

PG::Error: ERROR:  relation "geometry_columns" does not exist
LINE 1: SELECT * FROM geometry_columns WHERE f_table_name='wants'
                      ^
: SELECT * FROM geometry_columns WHERE f_table_name='wants'

Now, no idea what I'm doing wrong. Here are the steps I'm taking:

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list'
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.3-postgis pgadmin3 postgresql-contrib postgresql-server-dev-9.3
sudo -u postgres psql
    postgres=# CREATE EXTENSION adminpack;
    postgres=# CREATE EXTENSION postgis;
    postgres=# \q
    postgres=# CREATE USER abc WITH PASSWORD 'abc';
    postgres=# CREATE DATABASE abc;
    postgres=# CREATE DATABASE abc_development;

pg_restore --verbose --clean --no-acl --no-owner -h localhost -U abc -d abc abc-20131217-09.pgdmp
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U abc -d abc_development abc_development-20131217-09.pgdmp

Then navigate to cloned git folder and execute bundle and rails s

Here's the database.yml:

development: &dev
  # adapter: postgresql
  database: abc_development
  username: abc
  password: abc
  host: localhost
  encoding: utf8
  postgis_extension: true
  schema_search_path: public,postgis
  adapter: postgis
  encoding: utf8
  postgis_extension: postgis

production:
  adapter: postgis
  database: abc
  username: abc
  password: oTSZ1gQdwsFXWIUZsehj
  host: localhost
  encoding: utf8
  postgis_extension: true
  schema_search_path: public,postgis
  postgis_extension: postgis

Any ideas where it is going wrong? Help would be much appreciated.

2 Answers 2

1

Okay, I solved it somehow. Don't really know what did the trick but basically, it involved giving superuser privileges to "abc" user, then running db:create, db:migrate, importing db file from our site backups and running migrations again.

Sign up to request clarification or add additional context in comments.

1 Comment

This fixed my issue as well, but I have no idea what the database user was trying to do that required superuser permissions. I hope someone who has a better understanding can shed some light on it.
0

The error message is telling you that those tables do not exist in your database. You need to create migrations(basically just hunks of sql that rails can generate for you) then run rake db:migrate to run the migrations on your database.

You can read more about migrations at the rails guide to migrations.

1 Comment

No dice. Got bunch of migrations files (git clone comes from a fully working website, so do the database dumps), including one that should create the geometry_columns but when I run rake db:migrate it comes back with rake aborted! PG::Error: ERROR: relation "geometry_columns" does not exist LINE 1: SELECT * FROM geometry_columns WHERE f_table_name='schema_mi... ^ : SELECT * FROM geometry_columns WHERE f_table_name='schema_migrations' Any ideas then? Where I am going wrong?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.