code
stringlengths
1
1.73M
language
stringclasses
1 value
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) # Mayor.create(:name =>...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run CLBSArtDej::Application
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. # # Note: You'll currently still have to declare fixtures explicitly in integrati...
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
# 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
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attac...
Ruby
# Be sure to restart your server when you modify this file. CLBSArtDej::Application.config.session_store :cookie_store, :key => '_CLBS-Art-Dej_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table wi...
Ruby
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a probl...
Ruby
CLBSArtDej::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned...
Ruby
CLBSArtDej::Application.configure do # Settings specified here will take precedence over those in config/application.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 we...
Ruby
CLBSArtDej::Application.configure do # Settings specified here will take precedence over those in config/application.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 te...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application CLBSArtDej::Application.initialize!
Ruby
require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
Ruby
require File.expand_path('../boot', __FILE__) require 'rails/all' # If you have a Gemfile, require the gems listed there, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) if defined?(Bundler) module CLBSArtDej class Application < Rails::Application ...
Ruby
CLBSArtDej::Application.routes.draw do resources :messages get "dashboard/login" get "dashboard/logout" get "dashboard/index" resources :comp_evaluations resources :users resources :evaluation_result_camts resources :student_evaluation_seconds resources :job_requirements resources :companie...
Ruby
module ApplicationHelper end
Ruby
module CompEvaluationsHelper end
Ruby
module StudentEvaluationFirstsHelper end
Ruby
module UsersHelper end
Ruby
module JobRequirementsHelper end
Ruby
module ProductsHelper end
Ruby
module CompaniesHelper end
Ruby
module StudentEvaluationSecondsHelper end
Ruby
module MessagesHelper end
Ruby
module StudentStatusHelper end
Ruby
module StudentsHelper end
Ruby
module StoreHelper end
Ruby
module DashboardHelper end
Ruby
module EvaluationResultCamtsHelper end
Ruby
class Message < ActiveRecord::Base end
Ruby
class StudentEvaluationSecond < ActiveRecord::Base validates_presence_of :evaluator_name, :evaluator_position, :evaluator_department, :quantity_of_work, :quality_of_work, :academic_ability, :ability_to_learn, :practical_ability, :judgment, :management, :communication, :foreign_language, :suitability, :responsibi...
Ruby
class Student < ActiveRecord::Base validates_presence_of :firstname, :lastname, :firstname_th, :lastname_th, :status, :advisor, :nationality,:email, :emergency_contact_name, :computer_language, :dob, :emergency_contact_relationship,:emergency_email, :emergency_phone, :father_name, :gpa, :id_card_no, :language_eng...
Ruby
class StudentEvaluationFirst < ActiveRecord::Base validates_presence_of :evaluator_name, :evaluator_position, :evaluator_department, :quantity_of_work, :quality_of_work, :academic_ability, :ability_to_learn, :practical_ability, :judgment, :management, :communication, :foreign_language, :suitability, :responsibil...
Ruby
class Country < ActiveRecord::Base COUNTRY = [[ "Thailand", "Thailand"], ["Afghanistan", "Afghanistan"], ["Albania", "Albania"], ["Algeria", "Algeria"], ["Andorra","Andorra"], ["Angola", "Angola"], ["Antigua & Deps", "Antigua & Deps"], ["Argentina", "Argentina"], ["Arm...
Ruby
#--- # Excerpted from "Agile Web Development with Rails, 3rd Ed.", # published by The Pragmatic Bookshelf. # Copyrights apply to this code. It may not be used to create training material, # courses, books, articles, and the like. Contact us if you are in doubt. # We make no guarantees that this code is fit for any pur...
Ruby
class EvaluationResultCamt < ActiveRecord::Base end
Ruby
class Ability include CanCan::Ability def initialize(user) # Define abilities for the passed in user here. For example: # # user ||= User.new # guest user (not logged in) # if user.dashboard? # can :manage, :all # else # can :read, :all # end # # The first ar...
Ruby
class CompEvaluation < ActiveRecord::Base validates_presence_of :student_id, :student_name,:student_position,:student_department,:employer_name,:quality_of_work,:quantity_of_work,:academic_ability,:responsibility,:interest_in_work,:imitative,:response_to_supervision,:personality,:interpersonal_skills,:discipline,:et...
Ruby
class Product < ActiveRecord::Base validates_presence_of :title, :description, :image_url validates_numericality_of :price validate :price_must_be_at_least_a_cent validates_uniqueness_of :title validates_format_of :image_url, :with => %r{\.(gif|jpg|png|jpeg)$}i, :me...
Ruby
# coding: utf-8 class Student_status < ActiveRecord::Base STUDENT_STATUS = [ ["Available", "Available"], ["Accepted", "Accepted"] ] TITLE = [ ["Mr.", "Mr."], ["Ms.", "Ms."], ["Mrs.", "Mrs."]] TITLE_TH = [ ["นาย", "นาย"], ["นางสาว", "นางสาว"], ["นาง", "นาง"]] SEX = [ ...
Ruby
class Company < ActiveRecord::Base end
Ruby
class JobRequirement < ActiveRecord::Base end
Ruby
class CompaniesController < ApplicationController load_and_authorize_resource # GET /companies # GET /companies.xml def index @companies = Company.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @companies } end end # GET /companies/1 # GET ...
Ruby
class StudentEvaluationSecondsController < ApplicationController load_and_authorize_resource # GET /student_evaluation_seconds # GET /student_evaluation_seconds.xml def index @student_evaluation_seconds = StudentEvaluationSecond.all respond_to do |format| format.html # index.html.erb form...
Ruby
class EvaluationResultCamtsController < ApplicationController # GET /evaluation_result_camts # GET /evaluation_result_camts.xml def index @evaluation_result_camts = EvaluationResultCamt.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @evaluation_result_cam...
Ruby
class CompEvaluationsController < ApplicationController load_and_authorize_resource # GET /comp_evaluations # GET /comp_evaluations.xml def index @comp_evaluation = CompEvaluation.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @comp_evaluation } e...
Ruby
class DashboardController < ApplicationController # just display the form and wait for user to # enter a name and password def login if request.post? user = User.authenticate(params[:name], params[:password]) if user session[:user_id] = user.id uri = session[:original_uri] ...
Ruby
class ApplicationController < ActionController::Base protect_from_forgery before_filter :authorize, :except => :login helper :all protected def current_user current_user = User.find_by_id(session[:user_id]) end def authorize unless User.find_by_id(session[:user_id]) #session[:origin...
Ruby
class StudentsController < ApplicationController load_and_authorize_resource # GET /students # GET /students.xml def index @students = Student.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @students } end end # GET /students/1 # GET /stude...
Ruby
class MessagesController < ApplicationController # GET /messages # GET /messages.xml def index @messages = Message.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @messages } end end # GET /messages/1 # GET /messages/1.xml def show @messag...
Ruby
class StudentEvaluationFirstsController < ApplicationController load_and_authorize_resource # GET /student_evaluation_firsts # GET /student_evaluation_firsts.xml def index @student_evaluation_firsts = StudentEvaluationFirst.all respond_to do |format| format.html # index.html.erb format.xm...
Ruby
class JobRequirementsController < ApplicationController # GET /job_requirements # GET /job_requirements.xml def index @job_requirements = JobRequirement.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @job_requirements } end end # GET /job_require...
Ruby
class UsersController < ApplicationController load_and_authorize_resource # GET /users # GET /users.xml def index @users = User.order(:name) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @users } end end # GET /users/1 # GET /users/1.xml def...
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.expand_path('../config/application', __FILE__) require 'rake' CLBSArtDej::Application.load_tasks
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
source 'http://rubygems.org' gem 'rails', '3.0.5' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3' # Use unicorn as the web server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1....
Ruby
class CreateCompanyThs < ActiveRecord::Migration def self.up create_table :company_ths do |t| t.string :name t.string :address t.timestamps end end def self.down drop_table :company_ths end end
Ruby
class CreateStudentEvaluationFirsts < ActiveRecord::Migration def self.up create_table :student_evaluation_firsts do |t| t.string :student_id t.string :employer_name t.string :evaluator_name t.string :evaluator_position t.string :evaluator_department t.timestamps end end...
Ruby
class CreateJobRequirements < ActiveRecord::Migration def self.up create_table :job_requirements do |t| t.string :position t.integer :amount t.text :job_specification t.integer :salary t.string :ext_welfare t.timestamps end end def self.down drop_table :job_requi...
Ruby
class CreateCountries < ActiveRecord::Migration def self.up create_table :countries do |t| t.column :iso, :string, :size => 2 t.column :name, :string, :size => 80 t.column :printable_name, :string, :size => 80 t.column :iso3, :string, :size => 3 t.column :numcode, :integer t.t...
Ruby
class CreateEvaluationResultCamts < ActiveRecord::Migration def self.up create_table :evaluation_result_camts do |t| t.timestamps end end def self.down drop_table :evaluation_result_camts end end
Ruby
class StudentStatus < ActiveRecord::Migration def self.up end def self.down end end
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :name t.string :hashed_password t.string :salt t.timestamps end end def self.down drop_table :users end end
Ruby
class CreateStudents < ActiveRecord::Migration def self.up create_table :students do |t| t.string :firstname t.string :lastname t.boolean :status t.timestamps end end def self.down drop_table :students end end
Ruby
class AddRoleToUsers < ActiveRecord::Migration def self.up add_column :users, :role, :string end def self.down remove_column :users, :role end end
Ruby
class CreateStudentEvaluationSeconds < ActiveRecord::Migration def self.up create_table :student_evaluation_seconds do |t| t.timestamps end end def self.down drop_table :student_evaluation_seconds end end
Ruby
class CreateCompanies < ActiveRecord::Migration def self.up create_table :companies do |t| t.string :name t.text :address t.string :sub_district t.string :district t.string :province t.string :zip_code t.string :tel t.string :fax t.string :email t.string...
Ruby
class CreateMessages < ActiveRecord::Migration def self.up create_table :messages do |t| t.string :sender t.string :receiver t.string :subject t.text :body t.timestamps end end def self.down drop_table :messages end end
Ruby
class CreateStudentThs < ActiveRecord::Migration def self.up create_table :student_ths do |t| t.string :firstname t.string :lastname t.timestamps end end def self.down drop_table :student_ths end end
Ruby
class CreateCompEvaluations < ActiveRecord::Migration def self.up create_table :comp_evaluations do |t| t.string :student_id t.string :student_name t.string :employer_name t.string :student_position t.string :student_department t.timestamps end end def self.down dr...
Ruby
class Student < ActiveRecord::Migration def self.up end def self.down end end
Ruby
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) # Mayor.create(:name =>...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run CLBSArtDej::Application
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. # # Note: You'll currently still have to declare fixtures explicitly in integrati...
Ruby
require 'webrick' require 'json' require 'singleton' require 'digest/md5' Struct.new("Message", :from, :to, :body) def random_session_id # Borrowed from Ruby on Rails. md5 = Digest::MD5::new now = Time.now md5.update(now.to_s) md5.update(String(now.usec)) md5.update(String(rand(0))) md5.update(String($$)) md5...
Ruby
class ModifyClientUniqueId < ActiveRecord::Migration def self.up remove_column(:clients, :unique_id) add_column(:clients, :unique_id, :string) end def self.down remove_column(:clients, :unique_id) end end
Ruby
class AddRelationsInClient < ActiveRecord::Migration extend MigrationHelpers def self.up add_index(:clients, :county_id) add_index(:clients, :community_id) add_index(:clients, :clientstatus_id) add_index(:clients, :clientcategory_id) add_index(:clients, :foundmode_id) add_foreign_key(:client...
Ruby
class RemoveCountyFromClient < ActiveRecord::Migration extend MigrationHelpers def self.up remove_foreign_key(:clients, :county_id) remove_index :clients, :county_id remove_column :clients, :county_id end def self.down add_column :clients, :county_id, :integer add_index :clients, :county_i...
Ruby
class AddRoleDescription < ActiveRecord::Migration def self.up add_column :roles, :description, :string end def self.down remove_column :roles, :description end end
Ruby
class AddAdminUser < ActiveRecord::Migration def self.up role = Role.create( :name => "Administrator", :code => "Admin") role.save! user = User.create( :name => "admin", :password => '123', :role_id => role.id, :first_name => 'Admin', :last_name => 'Admin' )...
Ruby
class ModifyClient < ActiveRecord::Migration extend MigrationHelpers def self.up remove_column(:clients, :regitration_date) add_column(:clients, :registration_date, :datetime) add_column(:clients, :unique_id, :integer) add_index(:clients, :created_by_user_id) add_foreign_key(:clients,...
Ruby
class CreateCommunities < ActiveRecord::Migration def self.up create_table :communities do |t| t.string :name t.string :code t.timestamps end end def self.down drop_table :communities end end
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :name t.string :password_hash t.string :password_salt t.timestamps end end def self.down drop_table :users end end
Ruby
class CreateFoundmodes < ActiveRecord::Migration def self.up create_table :foundmodes do |t| t.string :name t.string :code t.timestamps end end def self.down drop_table :foundmodes end end
Ruby
class ModifyCommunity < ActiveRecord::Migration extend MigrationHelpers def self.up add_column :communities, :county_id, :integer add_index(:communities, :county_id) add_foreign_key(:communities, :county_id, :counties) end def self.down remove_column :communities, :county_id, :integer remov...
Ruby
class CreateClients < ActiveRecord::Migration def self.up create_table :clients do |t| t.string :first_name t.string :middle_name t.string :last_name t.string :spouse_first_name t.string :spouse_last_name t.string :spouse_middle_name t.string :address1 t.string :ad...
Ruby
class CreateCounties < ActiveRecord::Migration def self.up create_table :counties do |t| t.string :name t.string :code t.timestamps end end def self.down drop_table :counties end end
Ruby
class CreateRoles < ActiveRecord::Migration def self.up create_table :roles do |t| t.string :name t.string :code t.timestamps end end def self.down drop_table :roles end end
Ruby
class AddCountyToClient < ActiveRecord::Migration extend MigrationHelpers def self.down remove_foreign_key(:clients, :county_id) remove_index :clients, :county_id remove_column :clients, :county_id end def self.up add_column :clients, :county_id, :integer add_index :clients, :county_id ...
Ruby
class CreateClientcategories < ActiveRecord::Migration def self.up create_table :clientcategories do |t| t.string :name t.string :code t.timestamps end end def self.down drop_table :clientcategories end end
Ruby
class CreateClientstatuses < ActiveRecord::Migration def self.up create_table :clientstatuses do |t| t.string :code t.string :name t.timestamps end end def self.down drop_table :clientstatuses end end
Ruby
require "migration_helpers" class AddRoleToUser < ActiveRecord::Migration extend MigrationHelpers def self.up add_column :users, :role_id, :integer, :null =>false add_index(:users, :role_id) add_foreign_key(:users, :role_id, :roles) end def self.down remove_foreign_key(:users, :role_id) r...
Ruby
class AddFirstnameLastnameToUsers < ActiveRecord::Migration def self.up add_column :users, :first_name, :string, :null => false add_column :users, :last_name, :string, :null => false end def self.down remove_column :users, :first_name remove_column :users, :last_name end end
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
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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 Fast...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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 Fast...
Ruby