code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class ActsAsTaggableMigration < ActiveRecord::Migration
def self.up
create_table :tags do |t|
t.column :name, :string
end
create_table :taggings do |t|
t.column :tag_id, :integer
t.column :taggable_id, :integer
# You should make sure that the column created is... | Ruby |
class CreateBooks < ActiveRecord::Migration
def self.up
create_table :books do |t|
t.integer :user_id
t.string :title
t.string :isbn
t.timestamps
end
#add index
add_index :books, :user_id
#will need to add the index to condition later.
end
def self.down
dro... | Ruby |
class RemoveNeeded < ActiveRecord::Migration
def self.up
remove_column :books, :needed
end
def self.down
add_column :books, :needed, :boolean
end
end
| Ruby |
class AddConditionToBooks < ActiveRecord::Migration
def self.up
add_column :books, :condition_id, :integer
add_index :books, :condition_id
end
def self.down
remove_column :books, :condition_id
end
end
| Ruby |
class CreateConditions < ActiveRecord::Migration
def self.up
create_table :conditions do |t|
t.string :title
t.timestamps
end
end
def self.down
drop_table :conditions
end
end
| Ruby |
class AddCollegeToUsers < ActiveRecord::Migration
def self.up
add_column :users, :college_id, :integer
add_index :users, :college_id
end
def self.down
remove_column :users, :college_id
end
end
| Ruby |
class CreateColleges < ActiveRecord::Migration
def self.up
create_table :colleges do |t|
t.string :name
t.string :state
t.string :zip
t.timestamps
end
end
def self.down
drop_table :colleges
end
end
| Ruby |
class AddWantedNeededToBooks < ActiveRecord::Migration
def self.up
add_column :books, :wanted, :boolean
add_column :books, :needed, :boolean
end
def self.down
remove_column :books, :wanted
remove_column :books, :needed
end
end
| Ruby |
class AddSaltToUsers < ActiveRecord::Migration
def self.up
rename_column :users, :password, :encrypted_password
add_column :users, :salt, :string, :limit => 40
end
def self.down
remove_column :users, :salt
rename_column :users, :encrypted_password, :password
end
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :name
t.string :email
t.string :user_name
t.string :password, :limit => 40
t.timestamps
end
end
def self.down
drop_table :users
end
end
| Ruby |
class ModifyOffers < ActiveRecord::Migration
def self.up
# remove_index :offers, :offer_from_id
# remove_index :offers, :offer_to_id
remove_column :offers, :offer_to_id
remove_column :offers, :offer_from_id
add_column :offers, :for_book_id, :integer
add_column :offers, :offer_book_id, :... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test datab... | Ruby |
#!/usr/bin/ruby1.8
#!/usr/local/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performan... | Ruby |
#!/usr/bin/ruby1.8
#!/usr/local/bin/ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/... | Ruby |
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/request'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/request'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
module CollegeHelper
end
| Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def flash_notice
if flash[:notice]
content_tag('div', h(flash[:notice]), {:id => "flash_notice"})
end
end
end
| Ruby |
module ConditionHelper
end
| Ruby |
module UserHelper
end
| Ruby |
module SessionsHelper
end
| Ruby |
module StaticHelper
end
| Ruby |
module BookHelper
include TagsHelper
end
| Ruby |
class Offer < ActiveRecord::Base
has_many :book
validates_presence_of :offer_book_id
validates_presence_of :for_book_id
validates_presence_of :status
#To DO
#write a find method to get all ACTIVE of the offers for books that I own based on my ID
def self.get_offers_to_me(user_id)
find_by... | Ruby |
class Condition < ActiveRecord::Base
validates_presence_of :title
validates_uniqueness_of :title, :case_sensitive => false
end
| Ruby |
class Book < ActiveRecord::Base
acts_as_taggable
has_one :user
has_one :condition
#validation
validates_length_of :title, :within => 3..100
validates_presence_of :isbn
validates_presence_of :condition_id
validates_presence_of :user_id
validates_presence_of :tag_list
#comment
#class Met... | Ruby |
class College < ActiveRecord::Base
acts_as_taggable
validates_presence_of :name
validates_length_of :name, :within => 3..100
validates_presence_of :state
validates_uniqueness_of :name, :case_sensitive => false, :message => "That College already exists"
end
| Ruby |
class Status < ActiveRecord::Base
end
| Ruby |
class User < ActiveRecord::Base
has_one :college
#unencrypted password
attr_accessor :password
#validation
validates_length_of :email, :within => 3..100
validates_uniqueness_of :user_name, :case_sensitive => false
validates_presence_of :name
validates_presence_of :email
validates_presence_of ... | Ruby |
class UserController < ApplicationController
#This view is not needed any more.
def index
if !logged_in?
redirect_to :action => "login"
end
@users = User.find(:all)
end
#this is kind of like the home page for a user. It has their account info and the menu.
def show
@user = User.find(... | Ruby |
class StaticController < ApplicationController
def whytrade
end
def homepage
end
end
| Ruby |
class CollegeController < ApplicationController
def add
@college = College.new
end
def create
#create our college
@college = College.new(params[:college])
if @college.save #== @user
flash[:notice] = 'The College has been added'
redirect_to :controller => "college", :action => "i... | Ruby |
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
protect_from_forgery # :secret => 'ae8762dc36ffd7d6db94fbbed6c79b1c'
before_filter :initialize_user
... | Ruby |
class BookController < ApplicationController
#This is currently the home page, and the browse book method. It will eventually only do one.
def index
@all_books = Book.getAllBooks
@popular_books = Book.getAllBooks
@index_books = Book.find(:all, :conditions => ['ucase(left(title,1)) = ?',params[:lette... | Ruby |
class ConditionController < ApplicationController
def add
@condition = Condition.new
end
def create
#create our condition
@condition = Condition.new(params[:condition])
if @condition.save #== @user
flash[:notice] = 'Thanks'
redirect_to :controller => "condition", :action => "ind... | Ruby |
class OfferController < ApplicationController
def new
@user = User.find(session[:user])
@for_book = Book.find(params[:id])
@my_books = Book.getMyBooks(session[:user])
end
def create
@offer = Offer.new(:for_book_id => params[:for_book_id], :offer_book_id => params[:offer][:offer_book_id], :sta... | Ruby |
class SessionsController < ApplicationController
def new
end
def create
@current_user = User.authenticate(params[:email], params[:password])
if @current_user
session[:user] = @current_user.id
redirect_to :controller => "users", :action => "index", :id => @current_user.id
... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# i... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| Ruby |
ActionController::Routing::Routes.draw do |map|
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
# ... | Ruby |
set :application, "Book Trader"
set :repository, "http://bryantlarsencs4350.googlecode.com/svn/tags/DEPLOY_BOOKS"
set :domain, "books.azl.name"
set :user, "weberbooks"
set :use_sudo, false
set :deploy_to, "/home/weberbooks/books.azl.name/books/"
set :scm, "subversion"
role :app, domain
role :web, domain
role :db, ... | Ruby |
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
... | Ruby |
# Be sure to restart your server when you modify this file
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
#RAILS_GEM_VERSION = '2.... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Full error repor... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.ca... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between... | Ruby |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
| Ruby |
class CreateStatuses < ActiveRecord::Migration
def self.up
create_table :statuses do |t|
t.string :title
t.timestamps
end
end
def self.down
drop_table :statuses
end
end
| Ruby |
class CreateOffers < ActiveRecord::Migration
def self.up
create_table :offers do |t|
t.integer :offer_from_id
t.integer :offer_to_id
t.timestamps
end
#NEED HELP!
#this is where I need a foreign key to the book table.
add_index :offers, :offer_from_id
add_index :offers, :offe... | Ruby |
class ActsAsTaggableMigration < ActiveRecord::Migration
def self.up
create_table :tags do |t|
t.column :name, :string
end
create_table :taggings do |t|
t.column :tag_id, :integer
t.column :taggable_id, :integer
# You should make sure that the column created is... | Ruby |
class CreateBooks < ActiveRecord::Migration
def self.up
create_table :books do |t|
t.integer :user_id
t.string :title
t.string :isbn
t.timestamps
end
#add index
add_index :books, :user_id
#will need to add the index to condition later.
end
def self.down
dro... | Ruby |
class RemoveNeeded < ActiveRecord::Migration
def self.up
remove_column :books, :needed
end
def self.down
add_column :books, :needed, :boolean
end
end
| Ruby |
class AddConditionToBooks < ActiveRecord::Migration
def self.up
add_column :books, :condition_id, :integer
add_index :books, :condition_id
end
def self.down
remove_column :books, :condition_id
end
end
| Ruby |
class CreateConditions < ActiveRecord::Migration
def self.up
create_table :conditions do |t|
t.string :title
t.timestamps
end
end
def self.down
drop_table :conditions
end
end
| Ruby |
class AddCollegeToUsers < ActiveRecord::Migration
def self.up
add_column :users, :college_id, :integer
add_index :users, :college_id
end
def self.down
remove_column :users, :college_id
end
end
| Ruby |
class CreateColleges < ActiveRecord::Migration
def self.up
create_table :colleges do |t|
t.string :name
t.string :state
t.string :zip
t.timestamps
end
end
def self.down
drop_table :colleges
end
end
| Ruby |
class AddWantedNeededToBooks < ActiveRecord::Migration
def self.up
add_column :books, :wanted, :boolean
add_column :books, :needed, :boolean
end
def self.down
remove_column :books, :wanted
remove_column :books, :needed
end
end
| Ruby |
class AddSaltToUsers < ActiveRecord::Migration
def self.up
rename_column :users, :password, :encrypted_password
add_column :users, :salt, :string, :limit => 40
end
def self.down
remove_column :users, :salt
rename_column :users, :encrypted_password, :password
end
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :name
t.string :email
t.string :user_name
t.string :password, :limit => 40
t.timestamps
end
end
def self.down
drop_table :users
end
end
| Ruby |
class ModifyOffers < ActiveRecord::Migration
def self.up
# remove_index :offers, :offer_from_id
# remove_index :offers, :offer_to_id
remove_column :offers, :offer_to_id
remove_column :offers, :offer_from_id
add_column :offers, :for_book_id, :integer
add_column :offers, :offer_book_id, :... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test datab... | Ruby |
#!/usr/bin/ruby1.8
#!/usr/local/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performan... | Ruby |
#!/usr/bin/ruby1.8
#!/usr/local/bin/ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/... | Ruby |
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.