Skip to content

Instantly share code, notes, and snippets.

diff --git a/lib/fixjour/definitions.rb b/lib/fixjour/definitions.rb
index 9bebbc4..ee9bf8d 100644
--- a/lib/fixjour/definitions.rb
+++ b/lib/fixjour/definitions.rb
@@ -19,13 +19,11 @@ module Fixjour
# Defines the valid_*_attributes method
def define_valid_attributes(name)
define_method("valid_#{name}_attributes") do |*args|
- valid_attributes = send("new_#{name}").attributes
+ valid_attributes = send("new_#{name}", *args).attributes
if Book.exists?(:title => title) # SELECT #=> true/false
book = Book.find_by_title(title) # SELECT #=> Book
...
if book = Book.find_by_title(title) # SELECT || nil
...
if book = Book.find_by_title(title) && company = Company.find_by_name(name)
...
/*
* jQuery unwrap plugin
* GPL (GPL-LICENSE.txt) licenses.
* Created by: Tiziano Treccani
*
* $Date: 2008-1-06 12:00:00
*
* Version: 1.0
*/
$.extend({
param: function( a ) {
var s = [ ];
function add( key, value ){
s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value);
};
// If an array was passed in, assume that it is an array
// of form elements
if ( jQuery.isArray(a) || a.jquery )
$.extend({
param: function( a, nest_in ) {
var s = [ ];
// check for nest
if (typeof nest_in == 'undefined') nest_in = false;
function nested(key) {
if (nest_in)
return nest_in + '[' + key + ']';
else
// works like Prototype's Function#bind
// in Prototype:
// $('element').observe('click', this.clickMethod.bind(this));
// with jQuery + $.shove:
// $('#element).click($.shove(this.clickMethod, this));
$.extend({
shove: function(fn, object) {
return function() {
return fn.apply(object, arguments);
# HTML matcher for bacon
#
# it 'should display document' do
# body.should have_element('#document')
# end
#
# With content matching:
#
# it 'should display loaded document' do
# body.should have_element('#document .title', /My Document/)
# Given a class with an array of files as paths e.g.
# ['path/to/file.txt', 'other/file','path/file','file']
# Will organize them into a hash like
# {
# 'path' => {
# 'to' => {
# 'file' => {}
# },
# 'file' => {}
# },
(function($) {
$.extend(jqUnit, {
// like rspec/bacon describe, sort of
describe: function() {
var args = [].splice.call(arguments, 0);
return jqUnit.module('describe: ' + args.join(' '));
},
// shortcut to append 'should' to tests
On Ruby:
What got me and a lot of other people into ruby:
http://poignantguide.net/ruby/
Also the pickaxe (which an old version of is online for free):
http://whytheluckystiff.net/ruby/pickaxe/
All of these guys books are pretty great:
http://www.pragprog.com/titles