Skip to content

Instantly share code, notes, and snippets.

module Yajl
class HttpStream
class HttpError < StandardError; end
def self.get; end
end
end
class Sleeper
def sleep(delay)
sleep(delay)
module RaisableRedirections
def self.included(other)
other.send(:around_filter, :handle_raisable_redirections)
end
protected
def raise_redirect_to(*args)
raise Redirect.new(*args)
end
def create
@user = User.new(params[:user])
if @user.save_without_session_maintenance
@user.company.update_attributes(:owner_user_id => @user.id)
flash[:notice] = "Company registered!"
redirect_to login_url
else
render :action => :new
end
end
def activate
begin
@user = User.find_using_perishable_token!(params[:activation_code], 1.week)
rescue Exception => e
flash[:notice] = 'Either you activated it already Or that was an old request'
redirect_to login_url
else
if @user.activate!
@user.deliver_activation_confirmation!
flash[:notice] = 'Your username has been entered in the form below. Simply click Login to enter your account!'
# an assert_that method that accepts a Mocha parameter matcher
# based http://joe.truemesh.com/blog/000511.html by Joe Walnes
require 'test/unit'
require 'rubygems'
require 'mocha'
class MyTest < Test::Unit::TestCase
def test_equals
require 'test/unit'
require 'mocha'
class MyTest < Test::Unit::TestCase
class X
class << self
def foo(&block)
append_before_filter do
bar &block
def activate
@user = User.find_using_perishable_token(params[:activation_code], 1.week)
if @user && @user.activate!
@user.deliver_activation_confirmation!
flash[:notice] = 'Your username has been entered in the form below. Simply click Login to enter your account!'
redirect_to login_url(:email => @user.email)
else
flash[:notice] = 'Either you activated it already Or that was an old request'
redirect_to login_url
end
class CreateOrganizations < ActiveRecord::Migration
def self.up
create_table :organizations do |t|
end
end
end
class CreateChurches < ActiveRecord::Migration
def self.up
create_table :churches do |t|
class MyClass
def initialize(array)
@array = array
end
def do_stuff(&block)
@array.sort(&block)
end
# example 1
class WidgetsController < ApplicationController
before_filter :filter_1, :only => [:action_1, :action_2]
before_filter :filter_2, :only => [:action_2, :action_3]
before_filter :filter_3, :only => [:action_1, :action_3]
def action_1
# code