Published on

PostgreSQL

Authors
  • Name
    O. Anaedozie

Postgresql

Connecting to local PostgreSQL instance

psql -h localhost -p 5432 [database name]

Common psql commands

Note that a Relational Database is made up of logical units — tables.

\l List databases

\c Connect to a database

Within a database

\d List tables, views and sequences

\d [table name] Describe table, view, sequence, or index

https://stackoverflow.com/questions/39710384/cannot-connect-to-postgres-server-running-through-brew-services

Why do we need Apple’s Xcode Command Line tools for Ruby projects?

It gives developers access to Unix tools needed to install Ruby and develop applications. Xcode CLT provides a C language compiler needed to install Ruby gems with native extensions — some gems speed up Ruby by using code written in C language.

To add RSpec to your Ruby on Rails project, you can add the rspec-rails gem to your Gemfile:

group :development, :test do
  gem 'rspec-rails', '~> 5.0.0'
end

Then, run bundle install to install the gem.

Next, run the following command to generate the spec directory:

rails generate rspec:install

This will generate the necessary files and directories for RSpec.

You can then run your RSpec tests with the following command:

rspec

RSpec will automatically look for files in the spec directory and run any tests it finds.

For more information on using RSpec with Ruby on Rails, check out the RSpec Rails documentation.

Query string params as an array

?ids[]=1&ids[]=2&ids=3

Devise

What is devise_scope for?

Sets the devise scope to be used by controller. If you have custom routes, you are required to call this method in other to specify which controller to be targeted.

Creating a Rails model for a Home Owners Association would involve generating a new model through the rails generate model command. Here's an example of what the command and the resulting migration might look like:

rails generate model HomeOwner name:string email:string address:string

This command would generate a new migration file that creates a home_owners table with columns for name, email, and address.

Once the migration has been created, you can run rails db:migrate to apply the changes to your database.

After the model has been created, you can then define associations with other models, validations and other functionalities.

For more information on creating Rails models, check out the Rails documentation.

SELECT * FROM "public"."propertyManagementCompany" INNER JOIN "public"."users"
ON "public"."users"."propertManagementCompanyId" = "public"."propertyManagementCompany"."id