code
stringlengths
1
1.73M
language
stringclasses
1 value
class Announcement < ActiveRecord::Base belongs_to :osa validates_presence_of :message end
Ruby
class Award < ActiveRecord::Base belongs_to :organization validates_presence_of :name, :message => "of award can't be blank" end
Ruby
class EventsController < ApplicationController before_filter :login_required def index @current_user = Organization.find_by_account_id(session[:user_id]) @events = @current_user.events @editable = @current_user.editable end def new end def create @current_user = Organization.find_by_ac...
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 helper :all # include all helpers, all the time # See ActionController::RequestForgeryProtection for detail...
Ruby
class MainController < ApplicationController def index @announcements = Announcement.all end def login @current_user = Account.find_by_username_and_password( params[:login], params[:password]) if @current_user session[:user_id] = @current_user.id case @current_user.group ...
Ruby
require 'pdfdrawer' require 'find' class OsasController < ApplicationController before_filter :login_required def index @announcements = Announcement.all @pending = Organization.all(:conditions => "status = 'Application Pending'") @isopen = Osa.find_by_account_id(session[:user_id]).isopen end def ...
Ruby
require 'find' class OrganizationsController < ApplicationController before_filter :login_required def index @announcements = Announcement.find(:all) @current_user = Organization.find_by_account_id(session[:user_id]) end def new @current_user = Organization.find_by_account_id(session[:user_id]...
Ruby
class StudentsController < ApplicationController def index end def confirm @member = Member.find_by_confirmation_key(params[:id]) if @member @member.confirm = true @member.save flash[:notice] = "Confirmation Successful" redirect_to "/students/profile/#{params[:id]}" else flash[:error] = "INVAL...
Ruby
class AnnouncementsController < ApplicationController before_filter :login_required def new end def create @announcement = Osa.find_by_account_id(session[:user_id]).announcements.new(params[:announcement]) if @announcement.save @orgs = Organization.all for @org in @orgs Notifier.del...
Ruby
class MembersController < ApplicationController before_filter :login_required def create @current_user = Organization.find_by_account_id session[:user_id] @status = @current_user.status @editable = @current_user.editable @year = Time.now.year if Time.now.month >4 && Time.now.month <11 ...
Ruby
class NotifierController < ApplicationController def index end def get_password @organization = Organization.find_by_account_id(Account.find_by_username(params[:username])) if @organization == nil flash[:error] = "Username does not exist" elsif @organization.email_head == nil flash[:error] = "Ema...
Ruby
class AwardsController < ApplicationController before_filter :login_required def index @current_user = Organization.find_by_account_id(session[:user_id]) @awards = @current_user.awards @editable = @current_user.editable end def upload_certificate @current_user = Organization.find_by_account_id(s...
Ruby
class AccountsController < ApplicationController def index @accounts = Account.all end def show @account = Account.find(params[:id]) end def new @account = Account.new end def create @account = Account.new(params[:account]) if @account.save flash[:notice] = "Successfully...
Ruby
class EventReportsController < ApplicationController before_filter :login_required def index @current_user = Organization.find_by_account_id(session[:user_id]) @editable = @current_user.editable @year = Time.now.year if Time.now.month >4 && Time.now.month <11 @schoolyear = "#{@year.to_s}-#{(@year+1)....
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): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person',...
Ruby
# These settings change the behavior of Rails 2 apps and will be defaults # for Rails 3. You can remove this initializer when Rails 3 is released. if defined?(ActiveRecord) # Include Active Record class name as root for JSON serialized output. ActiveRecord::Base.include_root_in_json = true # Store the full clas...
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
# 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 # Enable threaded mode # config.threadsafe! # Use a different logger for distributed setups # config....
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
require "pdf/simpletable" class PdfDrawer def self.draw(org, filepath, bool) pdf = PDF::Writer.new(:paper => "A4") #form1------------------ pdf.text "<c:uline>Osa Form 1</c:uline>", :font_size => 10 pdf.text "<c:uline><b>INFORMATION SHEET FOR STUDENT ORGANIZATIONS</b></c:uline>", :justific...
Ruby
require "openssl" require "net/smtp" Net::SMTP.class_eval do private def do_start(helodomain, user, secret, authtype) raise IOError, 'SMTP session already started' if @started check_auth_args user, secret, authtype if user or secret sock = timeout(@open_timeout) { TCPSocket.open(@address, @po...
Ruby
class CreateOsas < ActiveRecord::Migration def self.up create_table :osas do |t| t.integer :account_id t.string :coordinator t.boolean :isopen, :default => false t.timestamps end end def self.down drop_table :osas end end
Ruby
class CreateAnnouncements < ActiveRecord::Migration def self.up create_table :announcements do |t| t.integer :osa_id t.text :message t.timestamps end end def self.down drop_table :announcements end end
Ruby
class CreateMembers < ActiveRecord::Migration def self.up create_table :members do |t| t.integer :student_id t.integer :organization_id t.string :position t.integer :semester t.integer :year t.boolean :confirm t.string :confirmation_key t.timestamps end end ...
Ruby
class CreateEventReports < ActiveRecord::Migration def self.up create_table :event_reports do |t| t.integer :organization_id t.string :name t.string :category t.string :description t.date :date t.string :venue t.string :head t.string :file_path1, :file_path2, :file_...
Ruby
class CreateOrganizations < ActiveRecord::Migration def self.up create_table :organizations do |t| t.integer :account_id t.string :name, :acronym, :nature, :category, :status, :approved_by t.string :mailing_address, :email_org, :email_head t.date :date_established, :date_incorporation, :da...
Ruby
class CreateAwards < ActiveRecord::Migration def self.up create_table :awards do |t| t.integer :organization_id t.string :name t.string :file_path t.string :classification t.string :description t.string :award_giving_body t.timestamps end end def self.down d...
Ruby
class CreateEvents < ActiveRecord::Migration def self.up create_table :events do |t| t.integer :organization_id t.string :name t.string :category t.string :description t.date :date t.string :venue t.string :head t.timestamps end end def self.down drop_...
Ruby
class CreateAccounts < ActiveRecord::Migration def self.up create_table :accounts do |t| t.string :username, :password, :group t.timestamps end end def self.down drop_table :accounts end end
Ruby
class CreateStudents < ActiveRecord::Migration def self.up create_table :students do |t| t.integer :student_no t.integer :year_level t.string :name #full name t.string :nickname t.string :degree_program #BS BA MS MA PHD PGA t.string :course t.string :college t.strin...
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
#!C:/ruby/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 impaired...
Ruby
#!C:/ruby/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.log #...
Ruby
#!C:/ruby/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 impaired...
Ruby
#!C:/ruby/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 impaired...
Ruby
#!C:/ruby/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.log #...
Ruby
#!C:/ruby/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 impaired...
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' $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" 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/dbconsole'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" 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/dbconsole'
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
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module OrganizationsHelper end
Ruby
module AccountsHelper end
Ruby
module EventsHelper end
Ruby
module OsasHelper end
Ruby
module StudentsHelper end
Ruby
module AnnouncementsHelper end
Ruby
module MembersHelper end
Ruby
module AwardsHelper end
Ruby
module NotifierHelper end
Ruby
module EventReportsHelper end
Ruby
module MainHelper end
Ruby
class Account < ActiveRecord::Base validates_presence_of :username, :password validates_uniqueness_of :username validates_length_of :password, :minimum => 5, :too_short => 'must be at least 5 characters long' end
Ruby
class Osa < ActiveRecord::Base belongs_to :account has_many :announcements end
Ruby
class EventReport < ActiveRecord::Base belongs_to :organization end
Ruby
class Student < ActiveRecord::Base has_many :members #set_primary_key "student_id" # validates_uniqueness_of :student_no end
Ruby
class Event < ActiveRecord::Base belongs_to :organization validates_presence_of :name, :message => "of activity can't be blank" end
Ruby
class Notifier < ActionMailer::Base def welcome_email(email,subj,password,username) recipients email from "Office of Student Activities <up.bukluran@gmail.com>" subject subj sent_on Time.now body :password => password, :username => username end def confirm_member(member, org) ...
Ruby
class DataFile < ActiveRecord::Base def self.open(filename, directory_path) f = File.open(directory_path+filename, 'r') return f end def self.save(upload, directory_path) name = upload['datafile'].original_filename directory = directory_path path = File.join(directory, name) ...
Ruby
class Member < ActiveRecord::Base belongs_to :student #, :foreign_key => "student_no" belongs_to :organization end
Ruby
class Organization < ActiveRecord::Base belongs_to :account has_many :events has_many :event_reports has_many :awards has_many :members validates_presence_of :name end
Ruby
class Announcement < ActiveRecord::Base belongs_to :osa validates_presence_of :message end
Ruby
class Award < ActiveRecord::Base belongs_to :organization validates_presence_of :name, :message => "of award can't be blank" end
Ruby
class EventsController < ApplicationController before_filter :login_required def index @current_user = Organization.find_by_account_id(session[:user_id]) @events = @current_user.events @editable = @current_user.editable end def new end def create @current_user = Organization.find_by_ac...
Ruby
class MainController < ApplicationController def index @announcements = Announcement.all end def login @current_user = Account.find_by_username_and_password( params[:login], params[:password]) if @current_user session[:user_id] = @current_user.id case @current_user.group ...
Ruby
require 'lib/pdfdrawer' require 'find' class OsasController < ApplicationController before_filter :login_required def index @announcements = Announcement.all @pending = Organization.all(:conditions => "status = 'Application Pending'") @isopen = Osa.find_by_account_id(session[:user_id]).isopen end ...
Ruby
require 'find' class OrganizationsController < ApplicationController before_filter :login_required def index @announcements = Announcement.find(:all) @current_user = Organization.find_by_account_id(session[:user_id]) end def new @current_user = Organization.find_by_account_id(session[:user_id]...
Ruby
class StudentsController < ApplicationController def index end def confirm @member = Member.find_by_confirmation_key(params[:id]) if @member @member.confirm = true @member.save flash[:notice] = "Confirmation Successful" redirect_to "/students/profile/#{params[:id]}" else flash[:error] = "INVAL...
Ruby
class AnnouncementsController < ApplicationController before_filter :login_required def new end def create @announcement = Osa.find_by_account_id(session[:user_id]).announcements.new(params[:announcement]) if @announcement.save @orgs = Organization.all for @org in @orgs Notifier.del...
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 helper :all # include all helpers, all the time # See ActionController::RequestForgeryProtection for detail...
Ruby