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 %>

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