Public Gists by ryanb

Gravatar
Fri Nov 20 14:33:57 -0800 2009
1
2
3
# Example of nested resource with CanCan
class CommentsController < ApplicationController
  before_filter :load_and_authorize_resource
Gravatar
Mon Nov 16 22:45:52 -0800 2009
1
2
3
class Ability
  include CanCan::Ability
  
Gravatar
Fri Nov 13 15:44:32 -0800 2009
1
2
3
==> Downloading http://downloads.sourceforge.net/project/ghostscript/GPL%20Ghost
File already downloaded and cached to /Users/rbates/Library/Caches/Homebrew
==> Downloading http://www.ijg.org/files/jpegsrc.v7.tar.gz
Gravatar
Wed Nov 11 09:41:16 -0800 2009
1
2
3
orders = {}
all_orders.group_by(&:ItemCode).each do |item_code, code_orders|
  orders[item_code] = {}
Gravatar
Tue Jul 07 13:21:14 -0700 2009
1
2
3
# Mimic Mac OS X Finder's sort by name.
class Array
  def finder_sort
Gravatar
Fri May 15 15:49:34 -0700 2009
1
2
3
class MockIO
  def initialize(receiver = nil)
    @buffer = ""
Gravatar
Fri May 15 09:22:20 -0700 2009
1
2
3
# COMMUNITY CHALLENGE
#
# How would you test this Quiz#problem method? Only two rules:
Gravatar
Thu Apr 16 14:11:33 -0700 2009
1
2
3
class Article < ActiveRecord::Base
  xapit do |index|
    index.text :description do |desc|
Gravatar
Tue Mar 24 14:55:01 -0700 2009
1
2
3
#!/bin/bash
 
case $1 in
Gravatar
Fri Feb 27 10:24:46 -0800 2009
1
2
3
class Tag
  has_many :taggings
  named_scope :important, :include => { :taggings => :important }
Gravatar
Thu Jan 22 17:44:42 -0800 2009
1
2
3
require 'rubygems'
require 'gosu'
 
Gravatar
Fri Sep 19 08:42:24 -0700 2008
1
2
3
/*
  PROBLEM:
  >> h = Hello.new('hi!')
Gravatar
Sun Sep 14 18:44:19 -0700 2008
1
2
3
# Examples of Nesting Associated Attributes
# This is a look at the various ways to set associated attributes through
# nested parameters. For example, let's say Project has_many :tasks and
Gravatar
Wed Aug 13 09:33:07 -0700 2008
1
2
3
def show
  @category = Category.find_by_permalink(params[:category])
  @page = @category.pages.find_by_permalink(params[:page])
Gravatar
Tue Aug 12 07:09:53 -0700 2008
1
2
3
# single controller
map.with_options :controller => 'info' do |info|
  info.about 'info/about', :action => 'about'
Gravatar
Sat Aug 09 09:55:40 -0700 2008
1
2
3
# AR Object dup vs marshal benchmarks
#
# re: http://rails.lighthouseapp.com/projects/8994/tickets/785
Gravatar
Tue Aug 05 11:10:04 -0700 2008
1
2
3
Creating a Multi Page Form in Rails
 
Creating a multi-step wizard-like form is pretty difficult in Rails.
Gravatar
Mon Jul 21 14:11:04 -0700 2008
1
2
3
def test_delete_middle
  assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)