code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
# Provides a model for instance-specific users.
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GNU Lesser... | Ruby |
# Listens for user creation and then handles email authentication
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/less... | Ruby |
# Provides a model for tags
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public Lice... | Ruby |
# Represents an incident within an instance of the application.
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser... | Ruby |
# Represents a criterion for a feed
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GNU Lesser General Pub... | Ruby |
# Join model between groups and updates
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GNU Lesser General... | Ruby |
# Represents a set of rules to aggregate updates within an incident
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/le... | Ruby |
# Represents a group of a group type within an instance
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GN... | Ruby |
# Represents a set of permissions that users can have
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GNU ... | Ruby |
# Join model between tag and group.
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GNU Lesser General Pub... | Ruby |
# Represents a tag belonging to an update
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GNU Lesser Gener... | Ruby |
class Attachment < ActiveRecord::Base
belongs_to :update
has_attached_file :attach,
:path => ":rails_root/attachments/:instance_id/:id/:basename.:extension",
:url => "/for/:instance_id/incidents/:incident_id/updates/:update_id/attachments/:id"
validates_attachment_size :attach, :less_than => 5.megabyte... | Ruby |
# Listens for user creation and then handles email authentication
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/less... | Ruby |
# Controller for operations on users in the database.
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GN... | Ruby |
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL)
class HomeControll... | Ruby |
# Controller for managing sitewide administrators.
# Admins are different from users; they do not belong to an instance
# and have all privileges.
# The list of admins can be accessed in /admins
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
#... | Ruby |
# Controller for handling managing roles.
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GNU Lesser Ge... | Ruby |
class AttachmentsController < ApplicationController
def show
instance = Instance.find(params[:instance_id])
incident = instance.incidents.find(params[:incident_id])
update = incident.updates.find(params[:update_id])
attachment = update.attachments.find(params[:id])
send_file(attachment.attach.p... | Ruby |
# Controller for handling logging in for users.
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GNU Les... | Ruby |
# Controller for operations on groups in the database.
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html G... | Ruby |
# Controller for handling logging in for users.
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GNU Les... | Ruby |
class MembershipsController < ApplicationController
def create
@instance = Instance.find(params[:instance_id])
@user = @instance.users.find(params[:user_id])
@group = @instance.groups.find(params[:group_id])
return with_rejection unless @user.updatable_by?(@current_user)
if params[:leave... | Ruby |
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL)
class ApplicationC... | Ruby |
# Controller for operations on incidents in the database.
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.htm... | Ruby |
# Controller for operations on group_types in the database.
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.h... | Ruby |
# Controller for operations on tags in the database.
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GNU... | Ruby |
# Controller for operations on users in the database.
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.html GN... | Ruby |
# Controller for operations on instances in the database.
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyleft/lesser.htm... | 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'
require 'find... | 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/runner'
| 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/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/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/plugin'
| 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/dbconsole'
| 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/console'
| 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/process/inspector'
| 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/reaper'
| 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/destroy'
| 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/server'
| 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/plugin'
| Ruby |
# Default Roles
normal = Role.create_or_update(:id => 1, :name => 'Normal User', :instance_id => 1)
group_chair = Role.create_or_update(:id => 2, :name => 'Group Chair', :instance_id => 1)
manager = Role.create_or_update(:id => 3, :name => 'Manager', :instance_id => 1)
admin = ... | Ruby |
#Default Admins
a = Admin.create_or_update(:id => 1, :email => 'blabla@bla.bla')
b = Admin.create_or_update(:id => 2, :email => 'blahblah@blah.blah')
a.salt = Digest::SHA1.hexdigest('bla')
a.crypted_password = a.generate_crypted_password('sahana123')
a.save
b.salt = Digest::SHA1.hexdigest('blah')
b.crypted_password = ... | Ruby |
#Default Group Types
GroupType.create_or_update(:id => 1, :name => 'Agency', :instance_id => 1)
GroupType.create_or_update(:id => 2, :name => 'Committee', :instance_id => 1)
GroupType.create_or_update(:id => 3, :name => 'Board', :instance_id => 2)
GroupType.create_or_update(:id => 4, :name => 'Agency', :instance_id => ... | Ruby |
#Linking the default data together
g1 = Group.find(1)
g2 = Group.find(2)
g3 = Group.find(3)
u1 = User.find(1)
u2 = User.find(2)
g1.users << u1
g1.users << u2
g2.users << u2
g3.users << u1
g1.chairs << u1
g1.chairs << u2
g2.chairs << u1
g3.chairs << u2
g1.save
g2.save
g3.save
up1 = Update.find(1)
up2 = Update.find(... | Ruby |
# Default Groups
Group.create_or_update(:id => 1, :name => 'Red Cross', :group_type_id => 1)
Group.create_or_update(:id => 2, :name => 'FBI', :group_type_id => 1)
Group.create_or_update(:id => 3, :name => 'City Hall', :group_type_id => 2)
Group.create_or_update(:id => 4, :name => 'HFOSS', :group_type_id => 3)
Group.cre... | Ruby |
#Default Instances
Instance.create_or_update(:id => 1, :short_name => 'nycoem', :long_name => 'New York City Office of Emergency Management')
Instance.create_or_update(:id => 2, :short_name => 'laoem', :long_name => 'Los Angeles Office of Emergency Management') | Ruby |
#Default Tags
t1 = Tag.create_or_update(:id => 1, :name => "GOVT", :instance_id => 1)
t2 = Tag.create_or_update(:id => 2, :name => "NGO", :instance_id => 1)
t3 = Tag.create_or_update(:id => 3, :name => "Important", :instance_id => 1)
t4 = Tag.create_or_update(:id => 4, :name => "Bronx", :instance_id => 1... | Ruby |
#Default Incidents
Incident.create_or_update(:id => 1, :name => 'Hurricane Luis', :description => 'Something Happened. Uh oh!', :instance_id => 1)
Incident.create_or_update(:id => 2, :name => 'Hurricane James', :description => 'Something Happened. Oh no!', :instance_id => 1)
Incident.create_or_update(:id => 3, :name =>... | Ruby |
#Default Carriers
Carrier.create_or_update(:id => 1, :name => 'AT&T', :extension => '@txt.att.net')
Carrier.create_or_update(:id => 2, :name => 'Boost', :extension => '@myboostmobile.com')
Carrier.create_or_update(:id => 3, :name => 'Cricket', :extension => '@sms.mycricket.com')
Carrier.create_or_update(:id => 4, :name... | Ruby |
UserObserver.disable!
# Default Users
john = User.create_or_update(
:id => 1, :first_name => 'John', :last_name => 'Smith',
:instance_id => 1, :email => 'blah@blah.com', :activation_code => '111',
:state => 'active', :cell_phone => '5857704551', :preferred_is_cell => true)
jane = User.create_or_update(
:id => ... | Ruby |
# Default Updates
u1 = Update.create_or_update(:id => 1, :title => 'First Update! YAY', :text => 'We have it all under control... nbd...', :user_id => 1, :incident_id => 1, :group_id => 1)
u2 = Update.create_or_update(:id => 2, :title => 'Nevermind!', :text => "I guess we don't really have it under control.. sowwy...",... | Ruby |
class CreateMemberships < ActiveRecord::Migration
def self.up
create_table :memberships do |t|
t.references :group
t.references :user
t.boolean :is_chair
end
end
def self.down
drop_table :memberships
end
end
| Ruby |
class CreateWhitelistedDomains < ActiveRecord::Migration
def self.up
create_table :whitelisted_domains do |t|
t.references :instance
t.string :name
t.timestamps
end
end
def self.down
drop_table :whitelisted_domains
end
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table "users", :force => true do |t|
t.column :first_name, :string, :limit => 100, :default => '', :null => true
t.column :last_name, :string, :limit => 100, :default => '', :null => true
t.column :emai... | Ruby |
class CreateCriterions < ActiveRecord::Migration
def self.up
create_table :criterions do |t|
t.string :kind
t.string :requirement
t.references :feed
t.timestamps
end
end
def self.down
drop_table :criterions
end
end
| Ruby |
class AddAttachmentCount < ActiveRecord::Migration
def self.up
add_column :updates, :attachments_count, :integer, :default => 0
Update.reset_column_information
Update.find(:all).each do |u|
Update.update_counters u.id, :attachments_count => u.attachments.size
end
end
def self.down
remo... | Ruby |
class AddLastLoginToUser < ActiveRecord::Migration
def self.up
add_column :users, :last_login, :datetime
add_column :users, :last_logout, :datetime
end
def self.down
remove_column :users, :last_login
remove_column :users, :last_logout
end
end
| Ruby |
class AddLastAlertedToUsers < ActiveRecord::Migration
def self.up
add_column :users, :last_alerted, :datetime
end
def self.down
remove_column :users, :last_alerted
end
end
| Ruby |
class AddAlertToFeeds < ActiveRecord::Migration
def self.up
add_column :feeds, :text_alert, :boolean
add_column :feeds, :email_alert, :boolean
end
def self.down
remove_column :feeds, :text_alert
remove_column :feeds, :email_alert
end
end
| Ruby |
class CreatePermissions < ActiveRecord::Migration
def self.up
create_table :permissions do |t|
t.string :model
t.string :action
t.timestamps
end
end
def self.down
drop_table :permissions
end
end
| Ruby |
class CreateGroupTypes < ActiveRecord::Migration
def self.up
create_table :group_types do |t|
t.string :name
t.references :instance
t.timestamps
end
end
def self.down
drop_table :group_types
end
end
| Ruby |
class CreateTags < ActiveRecord::Migration
def self.up
create_table :tags do |t|
t.string :name
t.references :instance
t.timestamps
end
end
def self.down
drop_table :tags
end
end
| Ruby |
class RemoveWantsAlertsFromUsers < ActiveRecord::Migration
def self.up
remove_column :users, :wants_alerts
end
def self.down
add_column :users, :wants_alerts, :boolean
end
end
| Ruby |
class ChangeUpdateTextColumnToText < ActiveRecord::Migration
def self.up
change_column :updates, :text, :text
end
def self.down
change_column :updates, :text, :string
end
end
| Ruby |
class CreateCarriers < ActiveRecord::Migration
def self.up
create_table :carriers do |t|
t.string :name
t.string :extension
t.timestamps
end
end
def self.down
drop_table :carriers
end
end
| Ruby |
class CreateIncidents < ActiveRecord::Migration
def self.up
create_table :incidents do |t|
t.string :name, :limit => 32
t.text :description
t.references :instance
t.timestamps
end
end
def self.down
drop_table :incidents
end
end
| Ruby |
class CreateGroups < ActiveRecord::Migration
def self.up
create_table :groups do |t|
t.string :name
t.references :group_type
t.timestamps
end
end
def self.down
drop_table :groups
end
end
| Ruby |
class CreateTaggings < ActiveRecord::Migration
def self.up
create_table :taggings do |t|
t.references :tag
t.references :update
end
end
def self.down
drop_table :taggings
end
end
| Ruby |
class CreateAdmins < ActiveRecord::Migration
def self.up
create_table :admins do |t|
t.string :email
t.string :crypted_password, :limit => 40
t.string :salt, :limit => 40
t.timestamps
end
end
def self.down
drop_table :admins
end
end
| Ruby |
class CreatePrivileges < ActiveRecord::Migration
def self.up
create_table :privileges do |t|
t.references :role
t.references :permission
t.timestamps
end
end
def self.down
drop_table :privileges
end
end
| Ruby |
class CreateAttachments < ActiveRecord::Migration
def self.up
create_table :attachments do |t|
t.string :name
t.column :attach_file_name, :string
t.column :attach_content_type, :string
t.column :attach_file_size, :integer
t.column :attach_updated_at, :datetime
t.references :upd... | Ruby |
class CreateFeeds < ActiveRecord::Migration
def self.up
create_table :feeds do |t|
t.string :name
t.text :description
t.references :owner
t.references :incident
t.timestamps
end
end
def self.down
drop_table :feeds
end
end
| Ruby |
class CreateUpdates < ActiveRecord::Migration
def self.up
create_table :updates do |t|
t.string :title
t.string :text
t.references :user
t.references :incident
t.references :group
t.timestamps
end
end
def self.down
drop_table :updates
end
end
| Ruby |
class CreateRoles < ActiveRecord::Migration
def self.up
create_table "roles" do |t|
t.string :name, :limit => 32
t.references :instance
t.timestamps
end
end
def self.down
drop_table "roles"
end
end | Ruby |
class AddMembershipsCount < ActiveRecord::Migration
def self.up
add_column :groups, :memberships_count, :integer, :default => 0
Group.reset_column_information
Group.all.each do |g|
Group.update_counters g.id, :memberships_count => g.memberships.size
end
end
def self.down
remove_column ... | Ruby |
class CreateInstances < ActiveRecord::Migration
def self.up
create_table :instances do |t|
t.string :short_name, :limit => 16
t.string :long_name
t.timestamps
end
end
def self.down
drop_table :instances
end
end
| Ruby |
class CreateGroupTaggings < ActiveRecord::Migration
def self.up
create_table :group_taggings do |t|
t.references :tag
t.references :group
end
end
def self.down
drop_table :group_taggings
end
end
| Ruby |
class CreateClassifications < ActiveRecord::Migration
def self.up
create_table :classifications do |t|
t.references :group
t.references :update
t.timestamps
end
end
def self.down
drop_table :classifications
end
end
| Ruby |
class AddClosedAtToIncidents < ActiveRecord::Migration
def self.up
add_column :incidents, :closed_at, :datetime
end
def self.down
remove_column :incidents, :closed_at
end
end
| Ruby |
class AddGroupsCount < ActiveRecord::Migration
def self.up
add_column :group_types, :groups_count, :integer, :default => 0
GroupType.reset_column_information
GroupType.find(:all).each do |gt|
GroupType.update_counters gt.id , :groups_count => gt.groups.count
end
end
def self.down
remo... | Ruby |
require 'active_record'
ActiveRecord::Base.class_eval do
def self.find_with_filters(*args)
join_conds = {}
column_conds = {}
fltrs = {}
args.each {|a| fltrs = a[:filters] if a.is_a?(Hash) && a.include?(:filters)}
fltrs.each_pair do |k,v|
if column_names.include?(k.to_s)
column_conds... | Ruby |
# Adds the check_perms method to ActiveRecord::Base (and thus all models)
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License:: http://www.gnu.org/copyl... | Ruby |
# Provides authentication features. Based closely on RESTful Authentication
# by Rick Olson (as attributed below).
#
# Author:: Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author:: Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright:: Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.