code
stringlengths
1
1.73M
language
stringclasses
1 value
Ed88::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 web serve...
Ruby
Ed88::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 test suite...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Ed88::Application
Ruby
#!/usr/bin/env rake # 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__) Ed88::Application.load_tasks
Ruby
class ResaveModelsAfterRemoveRedcloth < ActiveRecord::Migration def self.up # use built-in simple_format helper instead of redcloth, so re-save all models # to generate content_html column Event.find(:all).each {|event| event.save!} EventComment.find(:all).each {|cmt| cmt.save!} Group.find(:all)....
Ruby
class CreatePosts < ActiveRecord::Migration def self.up create_table :posts do |t| t.column :topic_id, :integer t.column :user_id, :integer t.column :content, :text t.column :content_html, :text t.column :created_at, :datetime t.column :updated_at, :datetime end end de...
Ruby
class CreateDisasterInfos < ActiveRecord::Migration def self.up create_table :disasteri_infos do |t| t.column :user_id, :integer t.column :title, :string t.column :content, :text t.column :content_html, :text t.column :important, :boolean t.column :created_at, :da...
Ruby
class AddEduTypeToSchool < ActiveRecord::Migration def self.up add_column :schools, :edu_type, :integer School.find(:all, :conditions => "is_meta=1").each do |s| s.edu_type=1 # 小学 s.save! end end def self.down remove_column :schools, :edu_type end end
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 AddPositionToGroups < ActiveRecord::Migration def self.up add_column "groups", "position", :integer, :default => 999 end def self.down remove_column "groups", "position" end end
Ruby
class AddSessions < ActiveRecord::Migration def self.up create_table :sessions do |t| t.column :session_id, :string t.column :data, :text t.column :updated_at, :datetime end add_index :sessions, :session_id add_index :sessions, :updated_at end def self.down drop_table :sess...
Ruby
class CreatePhotoComments < ActiveRecord::Migration def self.up create_table :photo_comments do |t| t.column :user_id, :integer t.column :photo_id, :integer t.column :title, :string t.column :content, :text t.column :content_html, :text t.column :created_at, :datetime t.c...
Ruby
class AddUrgencyNeedToSchool < ActiveRecord::Migration def self.up add_column :schools, :urgency_need, :string end def self.down remove_column :schools, :urgency_need end end
Ruby
class AddStudentIdToPhoto < ActiveRecord::Migration def self.up add_column :photos, :student_id, :integer end def self.down remove_column :photos, :student_id end end
Ruby
class CreatePhotos < ActiveRecord::Migration def self.up create_table :photos do |t| t.column :parent_id, :integer t.column :content_type, :string t.column :filename, :string t.column :thumbnail, :string t.column :size, :integer t.column :width, :integer t.column :height,...
Ruby
class CreateAreas < ActiveRecord::Migration def self.up create_table :areas do |t| t.column :parent_id, :integer t.column :lft, :integer t.column :rgt, :integer t.column :title, :string t.column :zipcode, :integer end end def self.down drop_table :areas end end
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table "users", :force => true do |t| t.column :login, :string t.column :email, :string t.column :crypted_password, :string, :limit => 40 t.column :salt, :str...
Ruby
class CreateBooks < ActiveRecord::Migration def self.up create_table :books do |t| t.column :user_id, :integer t.column :title, :string t.column :subtitle, :string t.column :author, :string t.column :isbn, :string t.column :publisher, :string t.column :description, :text ...
Ruby
class AddRefToEvent < ActiveRecord::Migration def self.up add_column :events, :ref, :string end def self.down remove_column :events, :ref end end
Ruby
class CreateSchools < ActiveRecord::Migration def self.up create_table :schools do |t| # app require t.column :area_id, :integer t.column :submitor_id, :integer t.column :info_source, :string t.column :is_validate, :boolean, :default => false t.c...
Ruby
class UpdateUsersAndSchoolsData < ActiveRecord::Migration def self.up User.find(:all).each do |u| u.save(false) end School.find(:all).each do |s| s.save(false) end end def self.down end end
Ruby
class AddBioHtmlToUser < ActiveRecord::Migration def self.up add_column :users, :bio_html, :text end def self.down remove_column :users, :bio_html end end
Ruby
class AddEvent < ActiveRecord::Migration def self.up create_table :events do |t| t.column :title, :string t.column :category, :integer t.column :start_at, :datetime t.column :end_at, :datetime t.column :location, :string t.column :content, :text t.column :content_html, :t...
Ruby
class CreateMessages < ActiveRecord::Migration def self.up create_table :messages do |t| t.column :sender_id, :integer t.column :receiver_id, :integer t.column :title, :string t.column :content, :text t.column :content_html, :text t.column :created_at, :datetime t.column ...
Ruby
class AddIsMetaToSchool < ActiveRecord::Migration def self.up add_column :schools, :is_meta, :boolean, :default => false School.find(:all, :conditions => "info_source='dizhen.1kg.org'").each do |s| s.is_meta = true end end def self.down remove_column :schools, :is_meta end end
Ruby
class CreateModeratorships < ActiveRecord::Migration def self.up create_table :moderatorships do |t| t.column :group_id, :integer t.column :user_id, :integer t.column :created_at, :datetime end end def self.down drop_table :moderatorships end end
Ruby
class CreateMugsOf < ActiveRecord::Migration def self.up create_table :mugs_of_schools do |t| t.column :photo_id, :integer t.column :school_id, :integer t.column :school_comment_id, :integer t.column :created_at, :datetime end create_table :mugs_of_events do |t| t.column...
Ruby
class AddRefToUsers < ActiveRecord::Migration def self.up add_column :users, :ref, :string # record user sign-up from where end def self.down remove_column :users, :ref end end
Ruby
class CreateTopics < ActiveRecord::Migration def self.up create_table :topics do |t| t.column :group_id, :integer t.column :user_id, :integer t.column :title, :string t.column :content, :text t.column :content_html, :text t.column :sticky, :boolean t.column :created_at, :...
Ruby
class RemoveDisasterInfos < ActiveRecord::Migration def self.up drop_table :disasteri_infos end def self.down end end
Ruby
class AddProfileToUser < ActiveRecord::Migration def self.up add_column :users, :last_name, :string add_column :users, :first_name, :string add_column :users, :gender, :integer add_column :users, :birth, :date add_column :users, :phone, :string add_column :users, :area_id, :integer add_col...
Ruby
class AddHiddenToGroups < ActiveRecord::Migration def self.up add_column "groups", "hidden", :boolean, :default => false end def self.down remove_column "groups", "hidden" end end
Ruby
class CreateGroupMemberships < ActiveRecord::Migration def self.up create_table :group_memberships do |t| t.column :group_id, :integer t.column :user_id, :integer t.column :created_at, :datetime end end def self.down drop_table :group_memberships end end
Ruby
class AddActivationToUsers < ActiveRecord::Migration def self.up add_column :users, :activation_code, :string, :limit => 40 add_column :users, :activated_at, :datetime User.find(:all).each do |u| u.activated_at = Time.now u.save(false) puts "UPDATE: #{u.email}" end end def ...
Ruby
class AddEventSchoolToPhoto < ActiveRecord::Migration def self.up add_column :photos, :event_id, :integer add_column :photos, :school_id, :integer end def self.down remove_column :photos, :event_id remove_column :phtots, :school_id end end
Ruby
class CreateRelationships < ActiveRecord::Migration def self.up create_table :relationships do |t| t.column :user_id, :integer t.column :neighbor_id, :integer t.column :created_at, :datetime end end def self.down drop_table :relationships end end
Ruby
class CreateBookCovers < ActiveRecord::Migration def self.up create_table :book_covers do |t| t.column :parent_id, :integer t.column :content_type, :string t.column :filename, :string t.column :thumbnail, :string t.column :size, :integer t.column :width, :integer t.column...
Ruby
class CreateSchoolComments < ActiveRecord::Migration def self.up create_table :school_comments do |t| t.column :user_id, :integer t.column :school_id, :integer t.column :include_update, :boolean t.column :title, :string t.column :content, :text t.column :content_html, :text ...
Ruby
class AddDescriptionHtmlToPhoto < ActiveRecord::Migration def self.up add_column :photos, :description_html, :text Photo.find(:all).each do |p| p.update_attributes!(:description => p.description) end end def self.down remove_column :photos, :description_html end end
Ruby
class CreateVisiteds < ActiveRecord::Migration def self.up create_table :visiteds do |t| t.column :user_id, :integer t.column :school_id, :integer t.column :visit_at, :date t.column :created_at, :datetime end end def self.down drop_table :visiteds end end
Ruby
class AddAdviceHtmlToSchool < ActiveRecord::Migration def self.up add_column :schools, :advice_html, :text end def self.down drop_column :schools, :advice_html end end
Ruby
class ReplaceContentWithContentHtmlAfterUsingTinymce < ActiveRecord::Migration def self.up Topic.find(:all).each do |topic| topic.content = topic.content_html topic.save(false) end end def self.down end end
Ruby
class CreateGroups < ActiveRecord::Migration def self.up create_table :groups do |t| t.column :creator_id, :integer t.column :title, :string t.column :content, :text t.column :content_html, :text t.column :created_at, :datetime t.column :updated_at, :datetime end end d...
Ruby
class CreateStudents < ActiveRecord::Migration def self.up create_table :students do |t| t.column :user_id, :integer t.column :school_id, :integer t.column :last_name, :string t.column :first_name, :string t.column :gender, :integer t.column :birth, :date t.column ...
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 # # 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 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 include TagsHelper def title_suffix "&middot;&nbsp; &middot;&nbsp; &middot;&nbsp; &middot;&nbsp; &middot;&nbsp; &middot;&nbsp;" end def error_msg(object, error, msg) return "<span class=\...
Ruby
module EventsHelper end
Ruby
module SchoolsHelper def tags_selector_for(input_field, tags) result = "" tags.each do |e| result << "<a href=\"javascript:swap('#{input_field}','#{e}')\">#{e}</a>&nbsp;" end return result end end
Ruby
module EventCommentsHelper end
Ruby
module Admin::GeneralHelper end
Ruby
module Admin::BaseHelper end
Ruby
module SessionsHelper end
Ruby
module TopicsHelper end
Ruby
module AreasHelper end
Ruby
module IntroHelper end
Ruby
module UsersHelper end
Ruby
module PostsHelper end
Ruby
module SchoolCommentsHelper end
Ruby
module MessagesHelper def message_link(message) if message.unread? "<strong>#{link_to message.title, message_url(message.id)}</strong>" else "<span class=\"tip\">#{link_to message.title, message_url(message.id)}</span>" end end end
Ruby
module PhotosHelper end
Ruby
module BooksHelper def book_manage_url url_for :controller => '/admin/general', :action => 'book_manage' end end
Ruby
module Dizhen::SchoolsHelper include ::SchoolsHelper def area_name(id) return Area.disasters.index(id).to_s end def count_display(count) color = count>0 ? "red" : "gray" "<span style=\"color:#{color}\">#{count}</span>" end end
Ruby
module Dizhen::BaseHelper =begin def nav_menu(text, url, session_name) if session[:nav] == session_name return link_to(text, url, :class => "now") else return link_to(text, url) end end =end def url_for_area(area_id) url_for :controller => 'schools', :action => 'area', :id => area_id...
Ruby
module Dizhen::GroupsHelper =begin def link_to_group_page(title, group_id) link_to title, :controller => '/dizhen/groups', :action => 'show', :id => group_id end =end end
Ruby
module GroupsHelper end
Ruby
module PhotoCommentsHelper end
Ruby
module SchoolServiceGroupsHelper end
Ruby
# == Schema Information # Schema version: 38 # # Table name: group_memberships # # id :integer(11) not null, primary key # group_id :integer(11) # user_id :integer(11) # created_at :datetime # class GroupMembership < ActiveRecord::Base belongs_to :user belongs_to :group end
Ruby