Skip to content

Instantly share code, notes, and snippets.

View thebucknerlife's full-sized avatar

Greg Buckner thebucknerlife

  • Los Angeles, CA
View GitHub Profile

N.B. Things that are starred with * are local variable

  • Ok, first generate a new rails app using this format:
    • rails new app_name
    • rails new amit_test_blog
  • Ok, next sketch out your models.
    • We're going to have two models for this blog: User and Post
    • One users can have many posts and many posts can belong to one users
    • Figure out the fields in each model.
    • Users will have these: field:type
@thebucknerlife
thebucknerlife / common_errors.md
Created April 4, 2014 03:12
Common errors from Rails

###undefined local variable or method ABC

###undefined method XYZ for Nil:NilClass

@thebucknerlife
thebucknerlife / authentication_with_bcrypt_in_rails_4.md
Last active January 17, 2024 23:54
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

Fenced code blocks inside ordered and unordered lists

  1. This is a numbered list.

  2. I'm going to include a fenced code block as part of this bullet:

    Code
    More Code
    
@thebucknerlife
thebucknerlife / ruby_and_rails_on_mavericks.md
Last active August 29, 2015 14:02
Installing Ruby & Rails on Mavericks

These steps are for Mavericks. Mileage will vary for older versions of Mac OS X but the broad strokes still apply. Google is your friend if you hit a snag. Comments welcome.

Installing Ruby & Rails on Mac OSX Mavericks

Install homebrew.

$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
{"new":[{"_id":"53aa49bfb05f9d0e45001879","id":"2014/06/25/120-sports-espn-cord-cutters","title":"120 Sports Wants to Be ESPN for Cord Cutters","title_tag":null,"author":"Jason Abbruzzese","post_date":"2014-06-25T00:01:55-04:00","post_date_rfc":"Wed, 25 Jun 2014 00:01:55 -0400","sort_key":"1wZEpd","link":"http://mashable.com/2014/06/25/120-sports-espn-cord-cutters/","content":{"plain":"Two of the largest U.S. professional sports leagues have entered into a joint venture to launch a new video startup tailored to mobile fans and cord cutters that miss being able to tune in to ESPN.\n\n120 Sports launched on Wednesday with equity stakes from Major League Baseball and the National Hockey League, as well as Time Inc., college-sports syndicator Campus Insiders and digital-sports media company Silver Chalice. The operation is already sizable with more than 130 staff based out of Chicago. \n\nSee also: 20 Funniest YouTube Videos According to Reddit\n\nThe startup features video on demand of sports highlights from pro
@thebucknerlife
thebucknerlife / carrierwave_future_url.md
Last active August 29, 2015 14:03
Carrierwave - Get future url before upload

Want to know the future location of a file upload? Want fast responses by moving file uploads into a background task with something like Sidekiq? Building an API and you want to immediately tell the client where the upload is going to be before actually uploading the file? Then try the tweaks below. This is definitely a monkey patch - mileage may vary.

class PhotoUploader < CarrierWave::Uploader::Base
  
  # Note:You've got to be using this option for the magic to work. It's
  # used by default, though, so you should be fine unless you commented
  # it out.
  #
  def store_dir
@thebucknerlife
thebucknerlife / aws_sns_tutorial.md
Last active August 29, 2015 14:03
Setup AWS Simple Notification Service (SNS) in Rails 4

Setup AWS Simple Notification Service (SNS) in Rails 4

This is a simple tutorial for setting up AWS SNS with Rails 4. A few details on the implementation:

  • Instead of saving a device_token as an attribute of Users, I save all SNS data and implementation with a separate model - SNSEndpoints.
  • SNS is region specific. I'm using us-west-1 as most of our startup's users are on the west coast. You can use whatever region you like (or the default), just keep in mind your AWS has to be configured for the same region as your SNS app (which you determine during setup in the AWS web console.

Tutorial

@thebucknerlife
thebucknerlife / rails_steps.md
Last active December 1, 2017 17:06
Rails App Steps

Steps in creating a basic rails app

  1. Define your model(s)
  • What tables should exist in the database?
  • What fields should each table have?
  1. Define your associations
  • What are the relationships between your tables?
  1. Generate models
  2. Create your controllers
@thebucknerlife
thebucknerlife / deploying_rails_to_heroku.md
Created October 20, 2014 23:41
A Beginners Guide to Deploying a Rails App on Heroku

Deploying to Heroku

This guide is for a first-time Rails developer to deploy their app to Heroku, a popular web-hosting service with strong Rails support. This guide assumes you already have a Heroku account and have installed the Heroku Toolbelt.

Create Your App and Setup Heroku with Git

  1. Make sure you've setup an SSH key for Heroku. Follow this simple guide to create an SSH key and send it to Heroku if needed: Heroku: Managing Your SSH Keys
  2. Navigate into the folder for your Rails app.