Skip to content

Instantly share code, notes, and snippets.

@mcoduti
mcoduti / installing_rails.md
Created March 5, 2016 20:29 — forked from raghubetina/installing_rails.md
Installing Ruby and Rails

Installing Ruby and Rails

Ruby is a wonderfully simple language, and Rails is an astonishingly powerful framework. Unfortunately, installing them can sometimes be the hardest part of learning to code.

In this guide I will lay out the least error-prone method of installing that we've found. Hopefully you will have no issues and it will be smooth sailing.

In case you do run into an error, first try restarting your computer and then re-try the last step that you got stuck on. If that doesn't work, we'll fix it together.

If you can't install Ruby on your laptop for some reason (for example, it belongs to your employer and you are not allowed to install things), skip to here.

@mcoduti
mcoduti / starter_generators.md
Created March 5, 2016 20:28 — forked from raghubetina/starter_generators.md
starter_generators Cheatsheet

starter_generators Cheatsheet

Include this in your Gemfile:

gem 'starter_generators', :git => "https://github.com/rbetina/starter_generators.git"

Then,

bundle install
@mcoduti
mcoduti / heroku.md
Created March 5, 2016 20:23 — forked from raghubetina/heroku.md
Heroku Cheatsheet

Heroku Cheatsheet

Get the Heroku toolbelt

Sign up for a Heroku account and install the toolbelt if you haven't already.

Prepare your application

In your Gemfile, add

@mcoduti
mcoduti / devise.md
Last active August 29, 2015 14:27 — forked from raghubetina/devise.md
Devise Cheatsheet

Authentication and Authorization with Devise

We will be using the [Devise gem][2] to help us get started with authentication (are you who you say you are?) and authorization (are you allowed to do/see this?).

Add sign-in/sign-out

  • Add gem 'devise' to your Gemfile and bundle
  • rails g devise:install

Devise will give you some setup instructions. We don't need to worry about most of them, but we do need to set a root URL. Usually, you will point the root URL to the index action of some important resource in your application: In config/routes.rb:

@mcoduti
mcoduti / command_line.md
Last active August 29, 2015 14:26 — forked from raghubetina/command_line.md
Command Line Cheatsheet

Command Line Cheatsheet

See what folder you are currently in

Mac

The "print working directory" command:

@mcoduti
mcoduti / design.md
Last active August 29, 2015 14:26 — forked from raghubetina/design.md
HTML, CSS, & Design Resources

Everything I Know About Front-End In One Handy List

As you go about designing and coding your application's screens, here are a few resources that you may find useful. In rough order of importance/handiness (in my experience).

Design

  • [Butterick's Typography In Ten Minutes][1] - A ten minute read that is guaranteed to make your content look better.
  • [Google Web Fonts][2] - You'll want this after reading Butterick's.
  • [Beautiful Web Type][3] and [Typographic Project][4] - A curated showcase of Google Web Fonts.
  • [Stock Up][6] - A search engine for free stock photos.
@mcoduti
mcoduti / sublime.md
Last active August 29, 2015 14:26 — forked from raghubetina/sublime.md
Sublime Setup Guide

One-Time Sublime Configuration

We are going to be writing all of our code using the plain text editor Sublime Text 3. In this guide, you will customize your installation with shortcuts and other things in order to make your life easier.

What follows may seem opaque, but don't worry about it -- we just need to go through this process once, and then we'll be all set for the quarter. You aren't expected to understand exactly how it is all working right now.

Installation

Download Sublime Text 3 (not 2) for your platform of choice [here][1], and install it (locate and double-click the file you just downloaded).

@mcoduti
mcoduti / rails_basics.md
Last active August 29, 2015 14:26 — forked from raghubetina/rails_basics.md
Rails Basic Commands

Rails Basic Commands

Generate a brand new application

cd to the folder where you want to store your new application. For me, this is ~/code. Then,

rails new my_app
@mcoduti
mcoduti / rcav.md
Last active August 29, 2015 14:26 — forked from raghubetina/rcav.md
RCAV Flowchart

RCAV Flowchart

Our apps are nothing more than a collection of URLs that we decide to allow users to access:

  • mydomain.com/products
  • mydomain.com/photos/193
  • mydomain.com/signin

So remember: everything always starts with a route between a URL we want to support and a Ruby method that will be responsible for generating a response to the user's browser.

@mcoduti
mcoduti / crud_with_ruby.md
Last active August 29, 2015 14:26 — forked from raghubetina/crud_with_ruby.md
CRUD with Ruby

CRUD with Ruby

Here is a quick reference on how to insert, retrieve, update, and delete rows from your database tables using our ActiveRecord-backed Ruby classes.

Adding Tables to the Database

First, we need a Ruby class to represent the real-world thing we're trying to model, and we need an underlying database table to store information about each individual thing.

Rails includes an easy generator to help us get set up with both of these things quickly. Supposed I wanted to create a table to store instructors, with two string columns first_name and last_name. I could use this shortcut from the Command Line: