Skip to content

Instantly share code, notes, and snippets.

View jasonswett's full-sized avatar

Jason Swett jasonswett

View GitHub Profile
<%= form_for(@client) do |f| %>
<% if @client.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@client.errors.count, "error") %> prohibited this client from being saved:</h2>
<ul>
<% @client.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
@jasonswett
jasonswett / gist:3388090
Created August 18, 2012 16:17
test cases
# single tag
find recipe
1 chicken alfredo
2 chicken pot pie
3 meatloaf
4 pasta primavera
5 spaghetti
# recipe AND chicken
find recipe chicken
FactoryGirl.define do
factory :employee do
# Your callback can be either for :build or :create, whichever
# makes the most sense for your situation.
after(:build) { |instance| instance.skills << create_list(:skill, 5) }
end
end
@jasonswett
jasonswett / Gemfile
Created November 24, 2013 17:16
Perpetuity Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.1'
# Use postgresql as the database for Active Record
gem 'pg'
gem 'perpetuity', git: 'git://github.com/jgaskins/perpetuity.git', ref: '82cad54d7226ad17ce25d74c751faf8f2c2c4eb2'
gem 'perpetuity-postgres', git: 'git://github.com/jgaskins/perpetuity-postgres.git', ref: 'c167d338edc05da582ff3856e86f7fb7693df0bb'
@jasonswett
jasonswett / appointment.rb
Created November 24, 2013 18:25
A fat model
class Appointment < ActiveRecord::Base
include ActionView::Helpers::NumberHelper
default_scope :order => "start_time asc"
scope :in_date_range, lambda { |start_date, end_date| self.in_date_range(start_date, end_date) }
scope :for_day, lambda { |date| in_date_range(date, date) }
scope :for_today, lambda { for_day(Time.zone.today) }
scope :for_tomorrow, lambda { for_day(Time.zone.today + 1.day) }
scope :not_time_blocks, joins(:time_block_type).where("code = 'APPOINTMENT'")
scope :checked_out, joins(:payments)
this.lunchHub = angular.module('lunchHub', []);
this.lunchHub.config([
'$routeProvider', function($routeProvider) {
return $routeProvider.when('/addresses', {
templateUrl: '../templates/addresses/index.html',
controller: 'AddressIndexCtrl'
}).when('/groups', {
templateUrl: '../templates/groups/index.html',
gulp.task('start-server', function() {
return server.listen(3000);
});
gulp.task('jasmine', function() {
return gulp.src('spec/test.js')
.pipe(jasmine());
});
gulp.task('test', ['start-server', 'jasmine'], function() {
gulp.task('test', function() {
server.listen(3000);
return gulp.src('spec/test.js')
.pipe(jasmine())
.on('end', function () {
server.close();
exit();
});
});
# Generated on 2014-11-05 using generator-angular 0.9.8
'use strict'
# # Globbing
# for performance reasons we're only matching one level down:
# 'test/spec/{,*/}*.js'
# use this if you want to recursively match all subfolders:
# 'test/spec/**/*.js'
module.exports = (grunt) ->
# Load grunt tasks automatically
# Generated on 2014-11-05 using generator-angular 0.9.8
'use strict'
# # Globbing
# for performance reasons we're only matching one level down:
# 'test/spec/{,*/}*.js'
# use this if you want to recursively match all subfolders:
# 'test/spec/**/*.js'
module.exports = (grunt) ->
# Load grunt tasks automatically