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 Post < ActiveRecord::Base | |
has_many :authors | |
attr_accessor :post_authors_cache | |
def post_authors_cache | |
@post_authors_cache ||= process_post_authors | |
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
# ------------------------------------------- | |
# 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 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
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 |
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
# 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 | |
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
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) { |
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
--- | |
:UY: Uruguay | |
:NP: Nepal | |
:BS: Bahamas | |
:HT: Haiti | |
:LK: Sri Lanka | |
:SE: Sweden | |
:DZ: Algeria | |
:TW: Taiwan | |
:GU: Guam |
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 '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"), |
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
# 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 | |
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 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 |
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
# 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) | |