|
|
|
|
|
by pjungwir
4681 days ago
|
|
A few ways I leverage Postgres in Rails: - CHECK constraints. I have a gem for setting up foreign keys and CHECK constraints in Rails: https://github.com/pjungwir/db_leftovers
- named scopes. You can include SQL snippets like this: class Publisher
scope :with_no_books, -> {
where <<-EOQ
NOT EXISTS (SELECT 1
FROM books b
WHERE publishers.id = b.publisher_id)
EOQ
}
end
Of course you can do this with MySQL too, but it's one way to nicely incorporate arbitrary SQL with your ORM, so that you can take advantage of any Postgres feature you want.- PostGIS: http://blog.daniel-azuma.com/archives/60 - hstore/json columns. |
|