Heroku : PostGreSQL : Dump production / staging database to localhost

$ heroku pg:backups capture -a app_name

this will be echoed in your screen

curl -oUse Ctrl-C at any time to stop monitoring progress; the backup
will continue running. Use heroku pg:backups info to check progress.
Stop a running backup with heroku pg:backups cancel.
DATABASE ---backup---> b001
Backup completed

 

then you need to download the dump using curl

$ curl -o latest.dump `heroku pg:backups public-url -a app_name`

 

then create a database in PG and make the dump import to that database

$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U [username] -d [database name] latest.dump
Example
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U john -d new_dump_database_name latest.dump
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U john -d production-dump prod

now config Rails’s Database.yml

development:
  <<: *default
  #  database: rails-app_development
  database: new_dump_database_name

 

Ruby On Rails : Case insensitive matching in Rails .where() clause

Its very easy to perform case insensitive searches in Rails as well as any SQL queries. SQL some useful functions to do so. Either you can UpCase or DownCase both the operands to perform such searching operations. Continue reading