Skip to content

Instantly share code, notes, and snippets.

View ggerdsen's full-sized avatar

Garrett Gerdsen ggerdsen

View GitHub Profile
@ggerdsen
ggerdsen / postgres-cheatsheet.md
Created December 12, 2020 20:36 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@ggerdsen
ggerdsen / rails http status codes
Created October 7, 2020 15:27 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@ggerdsen
ggerdsen / intermediate_sql.md
Created October 3, 2020 01:04 — forked from case-eee/intermediate_sql.md
Intermediate SQL

Intermediate SQL Workshop

  • Run psql
  • You may need to run CREATE DATABASE intermediate_sql;
  • To exit this shell, you can run CTRL d

Create tables

Let's create some tables in the database.

Rails Step By Step “Guide”

Start a new rails project:

Reference: https://github.com/turingschool-examples/task_manager_rails

This will start a new Rails App with postgresql as database and skip the usage of Spring and Turboline (method used in task_manager):

rails new task_manager -T -d="postgresql" --skip-spring --skip-turbolinks

@ggerdsen
ggerdsen / RAILS_CHEATSHEET.md
Created August 12, 2020 17:06 — forked from mdang/RAILS_CHEATSHEET.md
Ruby on Rails Cheatsheet

Ruby on Rails Cheatsheet

Architecture

Create a new application

Install the Rails gem if you haven't done so before

@ggerdsen
ggerdsen / feedback_from_me_sienna.md
Last active July 31, 2020 19:28 — forked from megstang/feedback_from_me.md
Project Feedback (Mod 1 && Mod 2)

Project Feedback

Name: Garrett

Partner: Sienna

Project Reflection

  • What is one thing that went unusually well during this project?
@ggerdsen
ggerdsen / render_and_redirect.markdown
Created July 31, 2020 18:43 — forked from jcasimir/render_and_redirect.markdown
Render and Redirect in Rails 3

Render and Redirect

The normal controller/view flow is to display a view template corresponding to the current controller action, but sometimes we want to change that. We use render in a controller when we want to respond within the current request, and redirect_to when we want to spawn a new request.

Render

The render method is very overloaded in Rails. Most developers encounter it within the view template, using render :partial => 'form' or render @post.comments, but here we'll focus on usage within the controller.

:action

@ggerdsen
ggerdsen / Rails models cheatsheet.md
Last active July 24, 2020 04:27 — forked from rstacruz/index.md
Rails cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@ggerdsen
ggerdsen / ActiveRecord Cheat Sheet v1.md
Last active August 1, 2020 20:45 — forked from jessieay/ActiveRecord Cheat Sheet v1
Active Record cheat sheet with examples of queries I've needed most so far

ActiveRecord cheat sheet / EXAMPLES

INSTALL

$ gem install activerecord in GEMFILE: gem ‘activerecord’

REQUIRE

require ‘active_record’