code
stringlengths
1
1.73M
language
stringclasses
1 value
# ============================================================================= # A set of rake tasks for invoking the Capistrano automation utility. # ============================================================================= # Invoke the given actions via Capistrano def cap(*parameters) begin require 'rubyg...
Ruby
#!/usr/bin/env ruby # An implementation of the Facebook[http://www.facebook.com] API as # documented at http://developers.facebook.com/documentation.php # # See Facebook::Session for details. # # Author:: Alpha Chen # Date:: 2006.08.18 require "digest/md5" require "hpricot" require "logger" require "net/https" requi...
Ruby
#!/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 performance is severely impai...
Ruby
#!/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 performance is severely impai...
Ruby
#!/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/log/fastcgi.crash.lo...
Ruby
#!/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 performance is severely impai...
Ruby
#!/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 performance is severely impai...
Ruby
#!/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/log/fastcgi.crash.lo...
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
require 'mytest_ext' module Mytest def hello puts MytestInt::hello() end module_function :hello end
Ruby
puts 'hello world' #require 'hello2'
Ruby
class CreateRelationships < ActiveRecord::Migration def self.up create_table :relationships do |t| t.column :code, :string t.column :description, :string end end def self.down drop_table :relationships end end
Ruby
class CreateRoles < ActiveRecord::Migration def self.up create_table :roles do |t| t.column :code, :string t.column :description, :string t.column :display_order, :integer t.column :active, :boolean, :default => false t.column :created_at, :string t.column :updated_at, :s...
Ruby
require 'migration_helpers' class CreateCommunications < ActiveRecord::Migration extend MigrationHelper::ForeignKeys def self.up create_table :communications do |t| t.column :communication_type_id, :integer t.column :student_id, :integer t.column :notes, :text end add_foreign_...
Ruby
class CreateGrades < ActiveRecord::Migration def self.up create_table :grades do |t| t.column :code, :string t.column :description, :string t.column :display_order, :integer t.column :active, :boolean, :default => false t.column :created_at, :string t.column :updated_at, ...
Ruby
class CreateSessions < ActiveRecord::Migration def self.up create_table :sessions do |t| t.column :start_date, :datetime t.column :end_date, :datetime t.column :created_at, :datetime t.column :updated_at, :datetime end end def self.down drop_table :sessions end end
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.column :role_id, :int t.column :address_id, :int t.column :username, :string, :limit => 10, :unique => true, :null => false t.column :hashed_password, :string, :null => false t.column :salt, :string ...
Ruby
require 'migration_helpers' class CreateTeachers < ActiveRecord::Migration extend MigrationHelper::ForeignKeys def self.up create_table :teachers do |t| t.column :address_id, :integer t.column :first_name, :string t.column :last_name, :string t.column :notes, :text t.column :em...
Ruby
require 'migration_helpers' class CreateAttendances < ActiveRecord::Migration extend MigrationHelper::ForeignKeys def self.up create_table :attendances do |t| t.column :student_id, :integer t.column :courses_sessions_id, :integer t.column :course_date, :date t.col...
Ruby
require 'migration_helpers' class CreateStudents < ActiveRecord::Migration extend MigrationHelper::ForeignKeys def self.up create_table :students do |t| t.column :address_id, :integer t.column :school_id, :integer t.column :first_name, :string, :null => false t.column :last_name, :st...
Ruby
require 'migration_helpers' class CreateCoursesSessions < ActiveRecord::Migration extend MigrationHelper::ForeignKeys def self.up create_table :courses_sessions do |t| t.column :session_id, :integer t.column :course_id, :integer t.column :teacher_id, :integer t.column :created_at, :...
Ruby
require 'migration_helpers' class CreateSchedules < ActiveRecord::Migration extend MigrationHelper::ForeignKeys def self.up create_table :schedules do |t| t.column :student_id, :integer t.column :courses_sessions_id, :integer t.column :session_id, :integer t.colu...
Ruby
require 'migration_helpers' class CreateAddresses < ActiveRecord::Migration extend MigrationHelper::ForeignKeys def self.up create_table :addresses do |t| t.column :street, :string t.column :city, :string t.column :state_id, :int #FK t.column :zipcode, :string, :...
Ruby
require 'migration_helpers' class CreateReportCards < ActiveRecord::Migration extend MigrationHelper::ForeignKeys def self.up create_table :report_cards do |t| t.column :grade_id, :integer t.column :courses_sessions_id, :integer t.column :report_date, :date t.co...
Ruby
class CreateCommunicationTypes < ActiveRecord::Migration def self.up create_table :communication_types do |t| t.column :code, :string t.column :description, :string t.column :display_order, :integer t.column :active, :boolean, :default => false t.column :created_at, :string ...
Ruby
class CreateStates < ActiveRecord::Migration def self.up create_table :states do |t| t.column :code, :string t.column :description, :string t.column :display_order, :integer t.column :active, :boolean, :default => false t.column :created_at, :string t.column :updated_at, ...
Ruby
class CreateCourses < ActiveRecord::Migration def self.up create_table :courses do |t| t.column :code, :string t.column :name, :string t.column :description, :string t.column :display_order, :integer t.column :active, :boolean, :default => ...
Ruby
require 'migration_helpers' class CreateSchools < ActiveRecord::Migration extend MigrationHelper::ForeignKeys def self.up create_table :schools do |t| t.column :address_id, :integer t.column :code, :string t.column :name, :string t.column :url, :string t.column :created_at, :da...
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
#!/opt/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 performance is severely impai...
Ruby
#!/opt/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/log/fastcgi.crash.lo...
Ruby
#!/opt/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 performance is severely impai...
Ruby
#!/opt/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 performance is severely impai...
Ruby
#!/opt/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/log/fastcgi.crash.lo...
Ruby
#!/opt/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 performance is severely impai...
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/breakpointer'
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/breakpointer'
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/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/generate'
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module SessionHelper end
Ruby
module TeacherHelper end
Ruby
module UserHelper end
Ruby
module StudentHelper end
Ruby
module CourseHelper end
Ruby
class Session < ActiveRecord::Base has_many :courses_sessions end
Ruby
class CoursesSessions < ActiveRecord::Base has_many :attendances belongs_to :course belongs_to :session belongs_to :teacher end
Ruby
class State < ActiveRecord::Base has_many :addresses end
Ruby
class Schedules < ActiveRecord::Base belongs_to :student belongs_to :course_session end
Ruby
class Student < ActiveRecord::Base belongs_to :address belongs_to :school has_many :attendances has_many :communications has_many :schedules def self.get_all @student = find(:all, :include => ['address', 'school'], :conditions => ['active = ?', true]) rescue ActiveRecord::RecordNotFound ...
Ruby
class Course < ActiveRecord::Base has_many :courses_sessions def self.get_all find(:all, :conditions => ['active = ? ', true]) end def self.get_by_id(id) find(id, :conditions => ['active = ?', true]) end def self.delete(id) conn = connection i = conn.update("UPDATE courses SET...
Ruby
class Communication < ActiveRecord::Base belongs_to :communication_type belongs_to :student end
Ruby
class School < ActiveRecord::Base belongs_to :address has_many :students end
Ruby
class Relationship < ActiveRecord::Base end
Ruby
class Teacher < ActiveRecord::Base belongs_to :address has_many :courses_sessions def Teacher.get_all find(:all, :include => ['address'], :conditions => ['active = ?', true]) rescue ActiveRecord::RecordNotFound nil end def Teacher.get_by_id(id) find(id, :include => ['address'], :co...
Ruby
require 'digest/sha1' class User < ActiveRecord::Base belongs_to :role belongs_to :address validates_length_of :username, :within => 3..10 validates_length_of :password, :within => 3...10 validates_presence_of :username, :password, :email, :password_confirmation, :salt validates_uniqueness_of :username,...
Ruby
class Role < ActiveRecord::Base has_many :users end
Ruby
class Attendance < ActiveRecord::Base belongs_to :student belongs_to :courses_sessions end
Ruby
class Address < ActiveRecord::Base has_many :schools has_many :students has_many :teachers has_many :users belongs_to :state end
Ruby
class CommunicationType < ActiveRecord::Base has_many :communications end
Ruby
class ReportCard < ActiveRecord::Base belongs_to :grade belongs_to :course_session end
Ruby
class Grade < ActiveRecord::Base has_many :report_cards end
Ruby
class UserController < ApplicationController def index end def create @user = User.new(params[:user]) @address = @user.address = Address.new(params[:address]) if @user.save flash[:notice] = 'User successfully created' APPLOG.info 'User # ' + @user.id.to_s + ' ...
Ruby
class CourseController < ApplicationController def index end def new @course = Course.new end def create @course = Course.new(params[:course]) if @course.save APPLOG.info 'Course #' + @course.id.to_s + ' ' + @course.name + ' added' flash[:notice] = 'Course successfully added ...
Ruby
class SessionController < ApplicationController def index end def new @session = Session.new end def create @session = Session.new(params[:session]) if @session.save APPLOG.info 'Session [' + @session.id.to_s + '] was saved' flash[:notice] = 'Session successfully added to the s...
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 # Pick a unique cookie name to distinguish our session data from others' session :session_key => '_classtrack...
Ruby
class TeacherController < ApplicationController def index end def new @teacher = Teacher.new end def create @teacher = Teacher.new(params[:teacher]) @address = @teacher.address = Address.new(params[:address]) if @teacher.save flash[:notice] = 'Teacher successfully added' AP...
Ruby
class StudentController < ApplicationController def index end def list @students = Student.get_all end def show @student = Student.get_by_id(params[:id]) end def new @student = Student.new @address = Address.new end def create @student = Student.new(params[:student]) @stud...
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
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb unless defined?(RAILS_ROOT) root_path = File.join(File.dirname(__FILE__), '..') unless RUBY_PLATFORM =~ /mswin32/ require 'pathname' root_path = Pathname.new(root_path).cleanpath(true).to_s end RAILS...
Ruby
# Be sure to restart your web 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 ...
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
# http://seb.box.re/articles/2006/07/29/foreign-key-and-rails-migration module MigrationHelper # Non-rails-standard helper to # facilitate managing foreign key constraints. module ForeignKeys def add_foreign_key(from_table, from_column, to_table) sql_statement = %W{ alter table #{from_table} ...
Ruby
module TestData SALT = "password salt" USER1_USERNAME = "lnguyen" USER1_PASSWORD = USER1_USERNAME USER1_HASHED_PASSWORD = "db87e7ab898ddd27b66fc07147720fa40bbae234" # lnguyen USER1_EMAIL = "lnguyen@hitachiconsulting.com" USER1_FIRSTNAME = "Loc" USER1_LASTNAME = "NGUYEN" USER2_USERNAME = "johndoe" ...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby