Skip to content

Instantly share code, notes, and snippets.

View workmad3's full-sized avatar

David Workman workmad3

View GitHub Profile
map.resources :forums, :shallow => true do |forum|
forum.resources :topics, :member => {:sort_asc => :get}, :shallow => true do |topic|
topic.resources :replies
end
end
@workmad3
workmad3 / routes
Created January 16, 2010 18:40 — forked from anonymous/routes
ActionController::Routing::Routes.draw do |map|
# twitter app stuff
map.connect '/accounts/callback', :controller => 'accounts', :action => 'callback'
map.resources :accounts, :collection => { :callback => :get}, :members => {:do_update => :post}
map.resources :feeds
map.resources :feed_entries
end
class Student
has_many :enrollments
has_many :courses, :through => :enrollments
has_many :submissions
has_many :assignments, :through => :submissions
end
class Enrollment
belongs_to :student
belongs_to :course
require 'autotest/growl'
require 'autotest/fsevent'
>> module ActiveRecord
>> class Base
>> end
>> end
=> nil
>> module ActiveRecord
>> class Error
>> def initialize
>> puts "AR::Error"
>> end
class Feed < ActiveRecord::Base
has_many :subscriptions
has_many :users, :through => :subscriptions
belongs_to :owner, :class_name => "User"
end
path File.expand_path('..', __FILE__)
source :gemcutter
gem "rails", "3.0.0.beta"
gem "rake", ">= 0.8.7"
gem "mocha", ">= 0.9.8"
if RUBY_VERSION < '1.9'
gem "ruby-debug", ">= 0.10.3"
# Use Bundler (preferred)
begin
require File.expand_path('../../.bundle/environment', __FILE__)
rescue LoadError
require 'rubygems'
require 'bundler'
Bundler.setup
# To use 2.x style vendor/rails and RubyGems
#
This example shows how to setup an environment running Rails 3 beta under 1.9.1 with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell))
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.1
# Use the ruby + gem set
∴ rvm 1.9.1%rails3
class Request < ActiveRecord::Base
before_save :reduce_users_karma
validate :validate_karma
def validate_karma
if user
errors.add(:karma, "You don't have enough karma") unless user.karma_current > karma
else
errors.add(:user, "No user in request")
end