This file contains 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
map.resources :forums, :shallow => true do |forum| | |
forum.resources :topics, :member => {:sort_asc => :get}, :shallow => true do |topic| | |
topic.resources :replies | |
end | |
end |
This file contains 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
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 |
This file contains 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 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 |
This file contains 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 'autotest/growl' | |
require 'autotest/fsevent' |
This file contains 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 ActiveRecord | |
>> class Base | |
>> end | |
>> end | |
=> nil | |
>> module ActiveRecord | |
>> class Error | |
>> def initialize | |
>> puts "AR::Error" | |
>> end |
This file contains 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 Feed < ActiveRecord::Base | |
has_many :subscriptions | |
has_many :users, :through => :subscriptions | |
belongs_to :owner, :class_name => "User" | |
end |
This file contains 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
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" |
This file contains 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
# 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 file contains 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 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 |
This file contains 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 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 |
OlderNewer