Skip to content

Instantly share code, notes, and snippets.

View thebucknerlife's full-sized avatar

Greg Buckner thebucknerlife

  • Los Angeles, CA
View GitHub Profile
<!-- app/views/users/new.html.erb -->
<h1>Signup!</h1>
<%= form_for :user, url: '/users' do |f| %>
Name: <%= f.text_field :name %>
Email: <%= f.text_field :email %>
Password: <%= f.password_field :password %>
Password Confirmation: <%= f.password_field :password_confirmation %>
# app/controllers/users_controller.rb
class UsersController < ApplicationController
def new
end
def create
end
# config/routes.rb
GifVault::Application.routes.draw do
# This route sends requests to our naked url to the *cool* action in the *gif* controller.
root to: 'gif#cool'
# I've created a gif controller so I have a page I can secure later.
# This is optional (as is the root to: above).
get '/cool' => 'gif#cool'

Intro to Ruby

###by thebucknerlife


#Ruby

  • Birthday: February 24, 1993
  • Creator: Yukihiro Matsumoto (Matz)
{"meta":{"code":200},"response":{"fallbackCategory":{"target":{"type":"path","url":"\/venue\/explore","params":{"query":"wifi","sw":"34.056183,-118.284454","ne":"34.100310,-118.232118"}},"refinements":[{"query":"coffee shop"}]},"suggestedFilters":{"header":"Tap to show:","filters":[{"name":"Open now","key":"openNow"},{"name":"$-$$$$","key":"price"}]},"geocode":{"what":"","where":"90026","center":{"lat":34.0766,"lng":-118.2646},"displayString":"90026, CA, United States","cc":"US","geometry":{"bounds":{"ne":{"lat":34.10031,"lng":-118.232118},"sw":{"lat":34.056183,"lng":-118.284454}}},"longId":"162411061580814818"},"headerLocation":"Current map view","headerFullLocation":"Current map view","headerLocationGranularity":"unknown","query":"wifi","totalResults":183,"suggestedBounds":{"ne":{"lat":34.109234265675475,"lng":-118.22999124722052},"sw":{"lat":34.04305066953355,"lng":-118.29043410836876}},"groups":[{"type":"Recommended Places","name":"recommended","items":[{"reasons":{"count":0,"items":[{"summary":"This spot
@thebucknerlife
thebucknerlife / boilerplate_layout_file.md
Created October 24, 2014 00:38
Boilerplate Rails Layout

Example Application Layout File

This is an example or boilerplate layout file. Your layout file is the frame rendered around every view in your app (via the <%= yield %> erb tag at the bottom). Every Rails app has a layout file at app/views/layouts/application.html.erb.

What's Included?

This layout file includes:

@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.
@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 / 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 / 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