GSto
GSto

Reputation: 42380

How to handle booleans in a Rails app with both SQLite and PostgreSQL?

I have a ruby on rails application where I am using SQLite for development and testing, and I am using PostgreSQL in production. How can I write queries that handle booleans in my models that can handle both cases? SQLite handles booleans by using 0 and 1 , and PostgreSQL uses t and f, which is causing my problems.

Upvotes: 0

Views: 47

Answers (1)

Benjamin Tan Wei Hao
Benjamin Tan Wei Hao

Reputation: 9701

Just use true/false. ActiveRecord will handle the rest.

So for example: Post.where(published: true)

Upvotes: 2

Related Questions