Skip to content

Instantly share code, notes, and snippets.

@JayK31
JayK31 / active_record.rb
Created March 18, 2014 16:29
active_record
require 'active_record'
ActiveRecord::Base.logger = Logger.new( STDOUT )
ActiveRecord::Base.establish_connection(
adapter: 'postgresql',
host: 'localhost',
username: 'jay',
database: 'food_db',
port: 5432
@JayK31
JayK31 / html.erb
Created March 20, 2014 13:07
html template
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
@JayK31
JayK31 / post_form.rb
Created March 25, 2014 18:12
post form
<form action="" method="post">
<input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>">
</form>
development: &defaults
adapter: postgresql
encoding: unicode
pool: 5
host: localhost
username: <%= `echo $USER`.chomp %>
password:
database: <%= File.basename(Rails.root) %>_development
test:

Setting up Guard with Rspec

Guard watches a directory and runs commands when it sees changes to files.

This is great for automating your rspec tests!

Set up

Add guard and guard-rspec to your Gemfile

@JayK31
JayK31 / Gemfile
Created April 8, 2014 15:32 — forked from phlco/Gemfile
# What about including `pry`, `rspec` or `guard`?
# They're loaded automatically as dependencies
group :development, :test do
# Annotates ActiveRecord Models, routes and others based on the database schema
gem "annotate"
# generates entity relationship diagrams based on Active Record models
# Postscript bugs may be fixed with:
HEROKU STEPS to SET UP:
1. git init
2. git add -A
3. git commit -m “”
4. heroku create
5. heroku keys:add → If there are any.
6. git push heroku master
Put in gemfile:
- rails 12factor gem
@JayK31
JayK31 / full_rails_gemfile.rb
Last active August 29, 2015 14:00
Full Rails Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.0'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
________________________________________________________________________
GIT HUB WITH PROJECTS
________________________________________________________________________
* git branch -d → Will delete the branch completely if it SUCKS.
* AlWAYS pull first before you start your work.
* git checkout develop → Never work on master branch.
- Your MASTER branch must always work.
________________________________________________________________________
----------------------------------------------------------------------
Steps to create Rails App
----------------------------------------------------------------------
1.) rails new app_name -d postgresql
'Jesse's way': rails g model Complaint descriptor:string address:string latitude:decimal longitude:decimal zip:integer
2.) database.yml → 'Phil's gist'
- put in: echo $USER in the terminal right after to make sure it works.
3.) rake db:create
4.) Insert ‘gem’ gist for development: