addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwchatcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgoogleimageimagesinstagramlinklocation-pinmagnifying-glassmailminusmoremuplabelShape 3 + Rectangle 1outlookpersonplusprice-ribbonImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruseryahoo

Re: [ruby-110] TIL about template option with pg gem in database.yml

From: Andrew M.
Sent on: Tuesday, October 23, 2012 4:18 PM


On Tue, Oct 23, 2012 at 4:11 PM, Brian <[address removed]> wrote:
When you're using PostGIS you need to make sure when you create a new database it uses the PostGIS database template.

Something like:

createdb -T my_postgis_template my_new_db_name

Hope that helps in the future.

correct. the problem was that I had a postgis template created, but I wasn't using it.
However, with out even thinking about it, I was doing what you just said manually.
setting the correct template in database.yml lets you use rake db:create without issues when you get to rake db:test:prepare
 


On Tuesday, October 23, 2012 at 3:58 PM, Andrew McElroy wrote:

> Greetings,
>
> At the last rails meetup I brought up a question about making rails + postgresql + postGIS + rspec work.
> It turns out that if you are using the pg gem, it supports template: option in database.yml.
> I wish this was better documented.
> It's completely obvious now that I figured it out, but I figured it doesn't hurt to post the answer.
>
> If you ever run into a situation where postgres is missing datatypes like geometry in my case, this is very likely the answer.
> I kind of wish that the pg gem would auto generate the template option in database.yml on a new rails project so that would explicitly know which template (if more than one exist for a user) you are using.
>
> The specific error message I was getting was: PG::Error: ERROR: relation "geometry_columns" does not exist.
> None of the current stackover flow answers that key on that error mention setting the template flag.
>
> Respectfully,
> Andrew McElroy
>
>
>
>
> --
> Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed] (mailto:[address removed]))
> This message was sent by Andrew McElroy ([address removed] (mailto:[address removed])) from The Nashville Ruby on Rails Meetup Group (http://www.meetup.com/nashvillerails/).
> To learn more about Andrew McElroy, visit his/her member profile (http://www.meetup.com/nashvillerails/members/10749993/)
> Set my mailing list to email me As they are sent (http://www.meetup.com/nashvillerails/list_prefs/?pref=1) | In one daily email (http://www.meetup.com/nashvillerails/list_prefs/?pref=2) | Don't send me mailing list messages (http://www.meetup.com/nashvillerails/list_prefs/?pref=0)
>
> Meetup, PO Box 4668 #37895 New York, New York[masked] (#) | [address removed] (mailto:[address removed])





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
http://www.meetup.com/nashvillerails/
This message was sent by Brian ([address removed]) from The Nashville Ruby on Rails Meetup Group.
To learn more about Brian, visit his/her member profile: http://www.meetup.com/nashvillerails/members/3438546/
Set my mailing list to email me

As they are sent
http://www.meetup.com/nashvillerails/list_prefs/?pref=1

In one daily email
http://www.meetup.com/nashvillerails/list_prefs/?pref=2

Don't send me mailing list messages
http://www.meetup.com/nashvillerails/list_prefs/?pref=0
Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]


People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy