Skip to content

Instantly share code, notes, and snippets.

View alexcalaca's full-sized avatar

Alexandre Calaça alexcalaca

View GitHub Profile
@alexcalaca
alexcalaca / How to set up Ruby on Rails 5 + PostgreSQL database on Cloud9.md
Last active January 13, 2022 18:48
How to set up Ruby on Rails 5 + PostgreSQL database on Cloud9

My profile: https://about.me/alexandrecalaca

1. Check your Rails version

rails -v
  1. Open the Gemfile and replace the line "gem 'sqlite3" with gem 'pg', '~> 0.21'
gem 'pg', '~> 0.21'
@alexcalaca
alexcalaca / Github-cheat sheet-my notes
Created May 8, 2018 01:34
Github-cheat sheet-my notes
Remove files from the repository based on your .gitignore without deleting them from the local file system
git rm --cached `git ls-files -i -X .gitignore`
@alexcalaca
alexcalaca / Markdown-cheat sheet-my notes.md
Last active May 16, 2018 22:56
Markdown-cheat sheet-my notes

This is block

\ It creates a line break

''' Test '''

Header

@alexcalaca
alexcalaca / How to remove RVM from cloud9.md
Last active April 13, 2024 15:40
How to remove RVM from cloud9
@alexcalaca
alexcalaca / How to install rbenv on Cloud9.md
Last active May 17, 2018 12:48
How to install rbenv on Cloud9
@alexcalaca
alexcalaca / How to create permalinks in Rails with the friendly_id gem.md
Created May 29, 2018 01:57
How to create permalinks in Rails with the friendly_id gem
@alexcalaca
alexcalaca / How to use enums in Rails.md
Last active May 29, 2018 22:58
How to use enums in Rails

Check my website: www.alexandrecalaca.com.br

  1. First of all, let's generate a migration that it is going to add a status attribute to the table.
rails generate migration add_post_status_to_blogs status:integer
  1. Open the migration you have just created. Your code needs to be something like this:
def change
    add_column :blogs, :status, :integer, default: 0
@alexcalaca
alexcalaca / Relationships in Rails.md
Created May 29, 2018 22:56
Relationships in Rails_

Visit my website: www.alexandrecalaca.com.br

In our example, there are2 models: Blog and Topic. Think about a single topic blog.

So, A blog can belong to only one topic. A topic has many different blogs.

Blog (N) X (1) topic The foreign key needs to be in the blog model.

@alexcalaca
alexcalaca / PostgreSQL command line cheatsheet-ac.md
Last active March 26, 2022 17:14
PostgreSQL command line cheatsheet-ac

PostgreSQL command line cheatsheet-ac.md

sudo -u postgres psql : Enter the console \password postgres : E

\du : List all users \l : List of databases \q : Disconnect