Skip to content

Instantly share code, notes, and snippets.

View brandoncordell's full-sized avatar

Brandon Cordell brandoncordell

View GitHub Profile
# Example - Let's write a function that prints a name
# This is RSpec, it's a testing framework. It's just like ruby in that it's made to be super readable. As you read the code, read it outloud like instructions
# We start with tests first
# We know that we need a function to print names. That's all we need. We
# use tests to keep us focused on the task. You'll write it piece by piece. Instead of writing the whole
# function, we'll break it up into responsibility chunks
/* ACL Tables */
CREATE TABLE acos (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
parent_id INT DEFAULT NULL,
model VARCHAR(255) DEFAULT '',
foreign_key INT UNSIGNED DEFAULT NULL,
alias VARCHAR(255) DEFAULT '',
lft INT DEFAULT NULL,
rght INT DEFAULT NULL
@brandoncordell
brandoncordell / gist:5505138
Created May 2, 2013 20:27
Problem destroying nested attributes
Started POST "/patients/4/prescribe" for 127.0.0.1 at 2013-05-02 16:24:39 -0400
Processing by PatientsController#prescribe as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Y8q2s/H4QzKVX8v03mXKg282kLEaNIwsztwVjQaJL7Q=", "patient"=>{"prescriptions_attributes"=>{"0"=>{"product_id"=>"2", "total_amount_prescribed"=>"100", "total_amount_prescribed_quantity"=>"Tablets", "amount_prescribed"=>"1", "amount_prescribed_quantity"=>"Tablets", "frequency"=>"Daily", "_destroy"=>"1", "id"=>"3"}, "1"=>{"product_id"=>"", "total_amount_prescribed"=>"", "total_amount_prescribed_quantity"=>"", "amount_prescribed"=>"", "amount_prescribed_quantity"=>"", "frequency"=>"", "_destroy"=>"0"}}}, "commit"=>"Update Patient", "patient_id"=>"4"}
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
{"utf8"=>"✓", "authenticity_token"=>"Y8q2s/H4QzKVX8v03mXKg282kLEaNIwsztwVjQaJL7Q=", "patient"=>{"prescriptions_attributes"=>{"0"=>{"product_id"=>"2", "total_amount_prescribed"=>"100",
@brandoncordell
brandoncordell / rspec-rails-response-codes.rb
Last active December 12, 2015 05:48
Rails reporting 404, rspec is reporting 200
# spec/controllers/pages_controller_spec.rb
require 'spec_helper'
describe PagesController do
describe "#show" do
context "with a published slug" do
...
end
@brandoncordell
brandoncordell / gist:3726415
Created September 15, 2012 05:10
Sorcery with Mongoid isn't persisting the username or email field
class User
include Mongoid::Document
authenticates_with_sorcery!
attr_accessor :username, :email, :password, :password_confirmation
attr_accessible :username, :email, :password, :password_confirmation
field :_id, type: String, default: -> { username.to_s.parameterize }
field :username, type: String
field :email, type: String
//
// BCOAuthController.h
// Bivy
//
// Created by Brandon Cordell on 8/1/12.
// Copyright (c) 2012 lead&rock. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <WebKit/WebKit.h>
// BCOAuthController.h
//
// BCOAuthController.h
// Bivy
//
// Created by Brandon Cordell on 8/1/12.
// Copyright (c) 2012 lead&rock. All rights reserved.
//
#import <Foundation/Foundation.h>
@user = User.new({
email: "user#{n}@7ey.es",
first_name: Forgery(:name).first_name,
last_name: Forgery(:name).last_name,
password: 'letmein',
remember_me: true,
})
class PagesController < HighVoltage::PagesController
def home
session[:coverage] = 10
end
end
# in the view (haml)
= debug session.inspect
# admin/dealers_controller.rb
class Admin::DealersController < Admin::BaseController
def new
@dealer = Dealer.new
7.times do |i|
@dealer.hours.build(day: i)
end
end