So Heroku's FAQ on using SQLite3 alongside Postgres basically consists of "Don't", so in the usual spirit of things, I'm out to make it work. Why you want to do this is up to you, for me it is because the Postgres gem forces the JSON gem to install with Native Extensions instead of just using JSON and all the university machines have ANSICON which breaks JSON via a registry entry. Also even if it did work I don't think they will let me install Postgres on their machines so SQLite3 is a must.
There were many pitfalls on the way to discovering this since I was stubborn but it turns out there is a really pretty and simple way to do this.
We must separate production from development and test as Heroku uses production.
In gemfile
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
And that is it.
Bask in Rails server for development in SQLite3,
Heroku login, Heroku create --stack cedar, Git push heroku master, Heroku run rake db:migrate, Heroku open.
Then revel in your working heroku production environment.
I even went so far as to play with many things like Bundle install --without production and rake db:migrate RAILS_ENV=development but you should not need to play with such things.
That is all.
No comments:
Post a Comment