Skip to content

Instantly share code, notes, and snippets.

View benvds's full-sized avatar
😀

Ben van de Sande benvds

😀
View GitHub Profile
# customer.rb
class Customer < ActiveRecord::Base
validates_presence_of :first_name
end
# customer_test.rb
require 'test_helper'
class CustomerTest < ActiveSupport::TestCase
should_validate_presence_of :first_name
end
# .gitignore for rails projects
config/database.yml
*~
*.cache
*.log
*.pid
tmp/**/*
.DS\_Store
db/cstore/**
@benvds
benvds / gist:170983
Created August 20, 2009 10:58
formtastic stylesheet changes to place input fields beneath labels
/* @override http://localhost:3000/stylesheets/formtastic_changes.css */
form.formtastic > li {
list-style: none;
margin: 0 0 1em 0;
}
form.formtastic > li > label {
display: block;
}
@benvds
benvds / disable autocomplete for textfields with class "autocomplete-off" with jQuery
Created August 25, 2009 18:35
disable autocomplete for textfields with class "autocomplete-off" using jQuery
//
// <input type="text" class="autocomplete-off" />
//
$(function(){
$('.autocomplete-off').attr('autocomplete', 'off');
});
@benvds
benvds / Controller test for default resource using Shoulda and Factory_Girl
Created August 26, 2009 07:41
Controller test for default resource using Shoulda and Factory_Girl
# posts_controller_test.rb
require 'test_helper'
class PostsControllerTest < ActionController::TestCase
context "on GET to :index" do
setup do
@first_post = Factory(:post, :title => "My first post")
@second_post = Factory(:post, :title => "My second post")
get :index
/* as described on: http://perishablepress.com/press/2009/12/06/new-clearfix-hack/ */
/* new clearfix */
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
@benvds
benvds / gist:285849
Created January 25, 2010 13:03
array_trim - trims given array recursively from empty values
// trims given array recursively from empty values
function array_trim($array) {
foreach ($array as $key => $value):
if(is_array($value)) {
$array[$key] = array_trim($value);
if(!count($array[$key])) unset($array[$key]);
} else {
if (empty($value)) unset($array[$key]);
}
endforeach;
/**
* @brief Splits an address string containing a street, number and number addition
*
* @param $streetStr string An address string containing a street, number (optional) and number addition (optional)
*
* @return array Data array with the following keys: street, number and numberAddition.
*/
private function split_street($streetStr) {
$aMatch = array();
# football
sm_home_win:
name: "1"
pick_type_category: sm
position: 1
sm_away_win:
name: "2"
pick_type_category: sm
→ rspec spec/models/profile_match_spec.rb
F*
Pending:
ProfileMatch.match matches all motives
# cant spec query chain
# ./spec/models/profile_match_spec.rb:46
Failures:
1) ProfileMatch.match matches against all companies