Skip to content

Instantly share code, notes, and snippets.

View bcardarella's full-sized avatar
Out sailing

Brian Cardarella bcardarella

Out sailing
View GitHub Profile
class ApplicationController < ActionController::Base
private
# To write subdomains on the url helpers:
# root_url(nil, {:subdomain => "subdomain"})
def url_for(options = nil)
case options
when Hash
if subdomain = options.delete(:subdomain)
# Mongoid association matchers for RSpec 2.x and 1.x
#
# Save this file to your spec/support directory
#
# Usage:
#
# describe User do
# it { should reference_one :profile }
# end
#
<% form_for(@book, :validations => { :options => { :submitHandler => "function(form){$(form).ajaxSubmit();}" } }) do |b| %>
...
I'm about to open up registration for RailsCamp New England #3 but I
would first like to raise some sponsorship.
Here is some information about the event:
What: Rails Camp New England is back for the 3rd event. The first took
place last summer in Maine, the 2nd in Rhode Island. We're continuing
the rotation of New England states with Vermont this time. It has been
the only continually organized Ruby event in New England. Twice a year
about 30 dedicated Rubyists get together for an extended weekend of
function cdgems() {
/usr/bin/osascript -e "tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down"
/usr/bin/osascript -e "tell application \"Terminal\" to do script with command \"cd $GEM_HOME/gems\" in window 1"
/usr/bin/osascript -e "tell application \"System Events\" to tell process \"Terminal\" to keystroke \"k\" using command down"
return 0
}
alias cdgems=cdgems
## Code
100.times do |i|
a = (100 * (i / 100.0)).to_s
puts a
end
## Output
0.0
1.0
2.0
source 'http://rubygems.org'
gem "i18n", ">= 0.4.0"
gem 'rails', '3.0.0'
gem "haml"
gem "compass"
# gem "mongoid", "2.0.0.beta.15"
@bcardarella
bcardarella / active_model_credit_card.rb
Created December 20, 2010 18:35
ActiveMerchant's Credit Card model updated to use ActiveModel::Validations
# Heavily borrowed from ActiveMerchant::Biling::CreditCard
# Updated for ActiveModel::Validations
class CreditCard
include ActiveMerchant::Billing::CreditCardMethods
include ActiveModel::Validations
include ActiveModel::Validations::Callbacks
include ActiveModel::Naming
## Attributes
require 'rubygems'
require 'test/unit'
require 'arel' # master
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3',
:database => ':memory:'
)
INNER JOIN "records_users" ON records_users AND "records_users" AND user_id AND "records_users"."user_id" AND users AND "users" AND id AND "users"."id" AND "records_users"."user_id" = "users"."id" INNER JOIN "records" ON records AND "records" AND id AND "records"."id" AND records_users AND "records_users" AND record_id AND "records_users"."record_id" AND "records"."id" = "records_users"."record_id"