Skip to content

Instantly share code, notes, and snippets.

class Post < ActiveRecord::Base
has_many :authors
attr_accessor :post_authors_cache
def post_authors_cache
@post_authors_cache ||= process_post_authors
end
# -------------------------------------------
# Simple PostgreSQL Configuration File v. 8.4
# -------------------------------------------
# This file provides a simple configuration with the most common options
# which most users need to modify for running PostgreSQL in production,
# including extensive notes on how to set each of these. If your configuration
# needs are more specific, then use the standard postgresql.conf, or add
# additional configuration options to the bottom of this file.
#
This example shows how to setup an environment running Rails 3 beta 3 under 1.9.2-head with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell)) or do 'rvm reload'
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.2-head
# Switch to 1.9.2-head and gemset rails3, create if it doesn't exist.
∴ rvm --create use 1.9.2-head@rails3
@hardbap
hardbap / photo.rb
Created April 18, 2010 18:02 — forked from kylefox/photo.rb
# How do I get Paperclip's post processor callbacks to run?
# The methods below don't seem to work.
# http://groups.google.com/group/paperclip-plugin/browse_thread/thread/d4ee841d5a7e00b2
####################################
# Define `after_post_process` in the model
class Photo < ActiveRecord::Base
has_attached_file :image
@hardbap
hardbap / gist:242390
Created November 25, 2009 01:25 — forked from rsl/gist:242387
function checkUploadQueue() {
var queueIsFinished = true;
var files = YAHOO.util.Dom.getChildren('file-list');
log.info(queueIsFinished);
i = files.length;
while(i--) {
if (typeof(files[i]) == object) {
---
:UY: Uruguay
:NP: Nepal
:BS: Bahamas
:HT: Haiti
:LK: Sri Lanka
:SE: Sweden
:DZ: Algeria
:TW: Taiwan
:GU: Guam
require 'ostruct'
class BugMash
# Prizes last updated 2009-08-07 12:04pm PDT
# http://wiki.railsbridge.org/projects/railsbridge/wiki/BugMash?version=41
def prizes
[
OpenStruct.new(:sponsor => "Jeff Cohen", :prize => "$100-off coupon code for any public Purple Workshops workshop"),
OpenStruct.new(:sponsor => "Mike Mangino", :prize => "Developing Facebook Platform Applications with Rails"),
OpenStruct.new(:sponsor => "Mike Gunderloy", :prize => "Rails Rescue Handbook"),
# Three things to add:
# * before_filter call
# * action_has_layout? method (if you have one, combine them)
# * adjust_for_inline
#
class ApplicationController < ActionController::Base
# ...
before_filter :adjust_for_inline
class Test::Unit::TestCase
def self.should_sum_total_ratings
klass = model_class
context "finding total ratings" do
setup do
@ratable = Factory(klass.to_s.downcase)
end
should "have zero total ratings if no rated talks" do
# Mailer.deliver_fancast_censored takes an argument, but shouldn't need to stub the arg...
stub(Mailer).deliver_fancast_censored
stub(Notifier).deliver
# trying to stub the create_ of course gives the same error.
mail = Notifier.create_password_reset_instructions(Factory(:user)) # => a tmail object
Notifier.deliver(mail)