Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@mikeauclair
mikeauclair / Basic Oi (Cucumber) Kimchi
Created September 24, 2011 19:38 — forked from jamis/Basic Oi (Cucumber) Kimchi
Basic Oi (Cucumber) Kimchi
BASIC OI (CUCUMBER) KIMCHI
--------------------------------------------------------------------------
Oi (cucumber) kimchi is a delicious, refreshing variation on the
traditional Korean kimchi recipe.
This particular recipe is a modified version of the recipe posted by Dr.
Ben Kim, at http://www.drbenkim.com/how-to-make-cucumber-kim-chi.htm.
--------------------------------------------------------------------------
@mikeauclair
mikeauclair / gist:1237551
Created September 23, 2011 14:53
bin mongo bundler
$ gem install bin
Successfully installed bson-1.4.0
Successfully installed mongo-1.3.1
Successfully installed multi_json-1.0.3
Successfully installed activesupport-3.1.0
Successfully installed bin-0.7.0
5 gems installed
$ gem dependency bin
Gem bin-0.7.0
activesupport (~> 3.1.0, runtime)
module AllIfAny
def validates_all_if_any(fields, options={})
fields = [fields].flatten
all_fields = fields.dup
validates_each(fields, options) do |record, attr_name, value|
if !(all_fields.find_all{|f| !record.send(f).to_s.empty?}.empty?)
record.errors.add(attr_name, (options[:message] || 'is invalid')) if value.to_s.empty?
end
end