This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Yajl | |
class HttpStream | |
class HttpError < StandardError; end | |
def self.get; end | |
end | |
end | |
class Sleeper | |
def sleep(delay) | |
sleep(delay) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'mocha' | |
class MyTest < Test::Unit::TestCase | |
class X | |
class << self | |
def foo(&block) | |
append_before_filter do | |
bar &block |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass | |
def initialize(array) | |
@array = array | |
end | |
def do_stuff(&block) | |
@array.sort(&block) | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |