Skip to content

Instantly share code, notes, and snippets.

@matthodan
matthodan / uploader_command
Created July 16, 2011 04:32
CarrierWave uploader generator
rails g uploader Photo
@matthodan
matthodan / Gemfile
Created July 16, 2011 04:26
Add these to your Gemfile
gem 'mini_magick'
gem 'carrierwave'
@matthodan
matthodan / jobs_controller.rb
Created February 13, 2011 09:13
jobs_controller.rb
class JobsController < ApplicationController
before_filter :require_user
ssl_required :index, :new, :create, :update, :destroy, :destroy_all
respond_to :html, :only => [:index, :new, :create, :destroy, :destroy_all]
respond_to :json, :only => [:index, :create, :update, :destroy]
[... omitted ...]
class User < ActiveRecord:Base
validate :user_is_happy_and_broke
private
def user_is_happy_and_broke
if self.state_of_mind != 'happy' || self.fiscal_status != 'broke'
errors.add :user_not_happy_and_broke, 'User must be happy and broke to continue'
end
end
end
<%= form_for @user do |f| %>
<%= f.text_field :name %>
<%= f.error_message_on :name %>
<% end %>
<%= error_messages_for :user %>
<%= form_for @user do |f| %>
<%= f.error_message_on :user_not_happy_and_broke %>
<% end %>
#!/usr/bin/env ruby
class Parent
private
def name
'Mommy'
end
end
class Child < Parent
credit_card = {
:type => '[cc type, e.g. 'visa']',
:number => '[cc number, from test account]',
:verification_value => '123',
:month => '[expiration month, from test account]',
:year => '[expiration year, from test account]',
:first_name => '[first name, can be anything]',
:last_name => '[last name, can be anything]',
:street_1 => '[street address, can be anything]',
:city => '[city, can be anything]',
require File.dirname(__FILE__) + '/paypal/paypal_common_api'
require File.dirname(__FILE__) + '/paypal_express'
require File.dirname(__FILE__) + '/paypal/paypal_recurring_payments' # Add this line
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class PaypalGateway < Gateway
include PaypalCommonAPI
...