Leahcim
Leahcim

Reputation: 41999

Rails: How to stop rails from trying to load postgres

I want to use sqlite3 but pg for production on heroku. However, I don't have postgres installed on local host, so bundle install doesn't work when I run the code below

I know there's something I can add to the code below so that rails doesn't try to install it when I run bundle install but i don't know what that is. Can anyone tell me?

#gem 'sqlite3'
group :development, :test do
  gem 'sqlite3'
end
group :production do
  gem 'pg'
end

Upvotes: 0

Views: 79

Answers (1)

Holger Just
Holger Just

Reputation: 55833

By default, bundler installs all defined groups. You have to tell it explicitly which groups you do not want. In this case it would probably be

bundle install --without production

Bundler will remember your choice of groups in .bundle/config. Consequently you should not check the contents of that directory into source control.

However you should note that there are various differences in the SQL dialect of SQLite and Postgres. So unless you do only trivial stuff, you should definitely test on Postgres too. Things like handling of dates, numerics and various string types differences with Postgres generally being much stricter. SQLite maps most of the datatypes to strings of infinite length. Postgres uses fixed data types which are enforced.

Upvotes: 2

Related Questions