code
stringlengths
1
1.73M
language
stringclasses
1 value
class PbcList < ActiveRecord::Base include AuthoredModel include AuthorizedModel include SanitizableAttributes attr_accessible :audit_cycle belongs_to :audit_cycle, :class_name => 'Cycle' has_many :requests, :dependent => :destroy has_many :control_assessments, :dependent => :destroy is_versioned_ex...
Ruby
class Option < ActiveRecord::Base include AuthoredModel include SanitizableAttributes attr_accessible :role, :title, :description, :required def to_s title end scope :options_for, lambda { |role| where(:role => role) } scope :ordered_by_title_desc, order("#{table_name}.title DESC") is_versioned_...
Ruby
class DataAsset < ActiveRecord::Base include AuthoredModel include SluggedModel include SearchableModel include AuthorizedModel include RelatedModel include SanitizableAttributes include BusinessObjectModel include DatedModel attr_accessible :title, :slug, :description, :url, :version, :start_date, :...
Ruby
# System to Control many to many class SystemControl < ActiveRecord::Base include CommonModel include StateModel attr_accessible :control, :system, :cycle belongs_to :control belongs_to :system belongs_to :cycle is_versioned_ext def self.by_system_control(system_id, control_id, cycle) sc = Syste...
Ruby
# Program to Directive many to many class ProgramDirective < ActiveRecord::Base include CommonModel attr_accessible :program, :directive belongs_to :program belongs_to :directive is_versioned_ext #def self.by_system_control(system_id, control_id, cycle) # sc = SystemControl # .where(:system_id =...
Ruby
require 'slugged_model' # A company / regulation control # class Control < ActiveRecord::Base include CommonModel include SluggedModel include SearchableModel include AuthorizedModel include RelatedModel include SanitizableAttributes include DatedModel CATEGORY_TYPE_ID = 100 CATEGORY_ASSERTION_TYPE_...
Ruby
class Risk < ActiveRecord::Base include AuthoredModel include SluggedModel include SearchableModel include AuthorizedModel include RelatedModel include SanitizableAttributes include DatedModel RATINGS = { 1 => "Minimal", 2 => "Moderate", 3 => "Significant", 4 => "Major", 5 => "Extre...
Ruby
# System to CO many to many relationship # `state` is the rolled up state from the System to Control association class SystemSection < ActiveRecord::Base include AuthoredModel include StateModel attr_accessible :section, :system belongs_to :section belongs_to :system is_versioned_ext end
Ruby
class Project < ActiveRecord::Base include AuthoredModel include SluggedModel include SearchableModel include AuthorizedModel include RelatedModel include SanitizableAttributes include BusinessObjectModel include DatedModel attr_accessible :title, :slug, :description, :url, :version, :start_date, :st...
Ruby
require 'authorization' # class to manage user accounts on CMS. Note that this class is different # than the Person class, because not all people responsible for compliance will # have an account. class Account < ActiveRecord::Base include AuthoredModel attr_accessor :password, :password_confirmation attr_acc...
Ruby
# A Program which links Directives # # The top of the Program -> Directive -> Control hierarchy class Program < ActiveRecord::Base include CommonModel include SluggedModel include SearchableModel include AuthorizedModel include RelatedModel include SanitizableAttributes include DatedModel KINDS = [ ...
Ruby
class RiskyAttribute < ActiveRecord::Base include AuthoredModel include SluggedModel include SearchableModel include AuthorizedModel include RelatedModel include SanitizableAttributes include DatedModel TYPE_STRINGS = %w(OrgGroup Product Facility Market Project DataAsset Process System) attr_accessi...
Ruby
class OrgGroup < ActiveRecord::Base include AuthoredModel include SluggedModel include SearchableModel include AuthorizedModel include RelatedModel include SanitizableAttributes include BusinessObjectModel include DatedModel attr_accessible :title, :slug, :description, :url, :version, :start_date, ...
Ruby
# Risk to RiskyAttribute many to many class RiskRiskyAttribute < ActiveRecord::Base include CommonModel attr_accessible :risk, :risky_attribute belongs_to :risk belongs_to :risky_attribute is_versioned_ext #def self.by_system_control(system_id, control_id, cycle) # sc = SystemControl # .where(:s...
Ruby
class Help < ActiveRecord::Base include AuthoredModel include SearchableModel include AuthorizedModel include SanitizableAttributes is_versioned_ext sanitize_attributes :content attr_accessible :title, :content, :slug end
Ruby
# Control to Risk many to many class ControlRisk < ActiveRecord::Base include CommonModel attr_accessible :control, :risk belongs_to :control belongs_to :risk is_versioned_ext #def self.by_control_risk(risk_id, control_id, cycle) # sc = ControlRisk # .where(:risk_id => risk_id, # :co...
Ruby
class RelationshipType < ActiveRecord::Base include AuthoredModel include SanitizableAttributes # attr_accessible :title, :body self.primary_key = 'relationship_type' has_many :relationships is_versioned_ext sanitize_attributes :description end
Ruby
# An Audit Cycle # # Used to group evidence for a particular audit of a program # start_at is the audit period start date. If missing, this is a continuous process. class Cycle < ActiveRecord::Base include CommonModel include AuthorizedModel include SanitizableAttributes include DatedModel attr_accessible :...
Ruby
class Transaction < ActiveRecord::Base include CommonModel include SanitizableAttributes attr_accessible :system, :title, :description belongs_to :system is_versioned_ext sanitize_attributes :description def display_name title end end
Ruby
class Request < ActiveRecord::Base include AuthoredModel include AuthorizedModel include SanitizableAttributes include DatedModel TYPES = { 1 => "Documentation", 2 => "Population Sample", 3 => "Interview" } STATUSES = [ "Draft", "Requested", "Responded", "Amended/Updated Requ...
Ruby
# A user session class UserSession < Authlogic::Session::Base extend ActiveModel::Naming authenticate_with Account cookie_key "_cms_cred" end
Ruby
class SectionSweeper < ActionController::Caching::Sweeper observe Section, ControlSection # TODO: monitor implementing_controls def after_create(section) expire_cache_for(section) end def after_update(section) expire_cache_for(section) end def after_destroy(section) expire_cache_for(sectio...
Ruby
class Meeting < ActiveRecord::Base include CommonModel attr_accessible :response, :start_at, :calendar_url belongs_to :response is_versioned_ext validates_presence_of :response, :calendar_url def display_name "#{response.system.title} meeting" end def calendar_url self[:calendar_url].gsub ...
Ruby
class Product < ActiveRecord::Base include AuthoredModel include SluggedModel include SearchableModel include AuthorizedModel include RelatedModel include SanitizableAttributes include BusinessObjectModel include DatedModel attr_accessible :title, :slug, :description, :url, :version, :type, :start_da...
Ruby
class Response < ActiveRecord::Base include AuthoredModel include AuthorizedModel attr_accessible :request, :system, :status, :population, :samples, :population_document, :sample_worksheet_document, :sample_evidence_document belongs_to :request belongs_to :system has_one :population_sample, :dependen...
Ruby
# A link between systems class SystemSystem < ActiveRecord::Base include AuthoredModel attr_accessible :parent, :child, :type, :order belongs_to :parent, :foreign_key => 'parent_id', :class_name => 'System' belongs_to :child, :foreign_key => 'child_id', :class_name => 'System' is_versioned_ext ...
Ruby
class Categorization < ActiveRecord::Base include AuthoredModel attr_accessible :category, :categorizable belongs_to :category belongs_to :categorizable, :polymorphic => true is_versioned_ext end
Ruby
class Market < ActiveRecord::Base include AuthoredModel include SluggedModel include SearchableModel include AuthorizedModel include RelatedModel include SanitizableAttributes include BusinessObjectModel include DatedModel attr_accessible :title, :slug, :description, :url, :version, :start_date, :sto...
Ruby
class ObjectPerson < ActiveRecord::Base include AuthoredModel include AuthorizedModel include RelatedModel include DatedModel attr_accessible :person, :personable, :notes, :start_date, :stop_date belongs_to :person belongs_to :personable, :polymorphic => true is_versioned_ext validates :role, :pre...
Ruby
class PopulationSample < ActiveRecord::Base include CommonModel attr_accessible :response, :population_document, :population, :sample_worksheet_document, :samples, :sample_evidence_document belongs_to :response belongs_to :population_document, :class_name => "Document" belongs_to :sample_worksheet_document...
Ruby
# A Person # # Normally an owner or otherwise responsbile for an audit function. class Person < ActiveRecord::Base include AuthoredModel include AuthorizedModel include RelatedModel attr_accessible :email, :name, :company, :language has_one :account has_many :object_people, :dependent => :destroy belo...
Ruby
class ControlControl < ActiveRecord::Base include AuthoredModel attr_accessible :control, :implemented_control belongs_to :control belongs_to :implemented_control, :class_name => 'Control' is_versioned_ext end
Ruby
class ControlSweeper < ActionController::Caching::Sweeper observe Control def after_create(control) expire_cache_for(control) end def after_update(control) expire_cache_for(control) end def after_destroy(control) expire_cache_for(control) end private def expire_cache_for(control) #...
Ruby
# A Document # # Can either be linked by a URL or attached from Google Docs. class Document < ActiveRecord::Base include AuthoredModel include AuthorizedModel include RelatedModel include SanitizableAttributes VALID_SCHEMES = ['http', 'https', 'file'] attr_accessible :link, :title, :description, :type, :k...
Ruby
module ErrorWarningMessageObject attr_accessor :errors, :warnings, :messages def initialize @base_errors = [] @errors = HashWithIndifferentAccess.new @base_warnings = [] @warnings = HashWithIndifferentAccess.new @base_messages = [] @messages = HashWithIndifferentAccess.new super end...
Ruby
class SectionRowConverter < BaseRowConverter @model_class = :Section def setup_object object = setup_object_by_slug(attrs) if object.directive.present? && object.directive != @importer.options[:directive] add_error(:slug, "Code is used in #{object.directive.meta_kind.to_s.titleize}: #{object.direc...
Ruby
class SystemRowConverter < BaseRowConverter @model_class = :System def setup_object object = setup_object_by_slug(attrs) if object.new_record? object.infrastructure = false if object.infrastructure.nil? object.is_biz_process = true if @importer.options[:is_biz_process] else if object...
Ruby
class ControlRowConverter < BaseRowConverter @model_class = :Control def setup_object object = setup_object_by_slug(attrs) if object.directive.present? && object.directive != @importer.options[:directive] add_error(:slug, "Code is used in #{object.directive.meta_kind.to_s.titleize}: #{object.directi...
Ruby
require 'csv' class ImportException < Exception end class BaseConverter attr_accessor :rows, :objects, :all_objects, :options, :warnings, :errors, :slugs def initialize(rows_or_objects, options=nil) @options = options || {} if @options[:export] @objects = rows_or_objects @rows = [] els...
Ruby
class RiskRowConverter < BaseRowConverter @model_class = :Risk def setup_object object = setup_object_by_slug(attrs) if !object.new_record? add_warning(:slug, "Risk already exists and will be updated") end end def reify handle(:slug, SlugColumnHandler) handle(:controls, LinkControl...
Ruby
class HelpController < ApplicationController layout 'help' # access_control :acl do # allow logged_in # end # Render the requested partial under 'help' def edit slug = params[:help]['slug'] @help = Help.find_by_slug(slug) || Help.new(:slug => slug) @help.title = params[:help]['title'] ...
Ruby
# Browse programs class ProgramsController < BaseObjectsController # access_control :acl do # allow :superuser # # actions :new, :create do # allow :create, :create_program # end # # actions :edit, :update do # allow :update, :update_program, :of => :program # end # # actions :show, :toolt...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Handle Products class ProductsController < BusinessObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :index do # allow :read,...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 class AccountsController < BaseObjectsController # access_control :acl do # allow :superuser # # actions :new, :create do # allow :create, :create_account # end # # actions :edit, :update do...
Ruby
class ObjectDocumentsController < BaseMappingsController # access_control :acl do # allow :superuser # # actions :index do # allow :read, :read_object_document # end # # actions :create do # allow :create, :create_object_document # end # # actions :list_edit, :create do # allow :updat...
Ruby
class ControlRisksController < BaseMappingsController # access_control :acl do # allow :superuser # end def index @objects = ControlRisk if params[:risk_id].present? @objects = @objects.where(:risk_id => params[:risk_id]) end if params[:control_id].present? @objects = @objects.where...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Handle facilities class FacilitiesController < BusinessObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :new, :create do # a...
Ruby
# Handle PBC Lists require 'csv' class ImportException < Exception end class PbcListsController < BaseObjectsController include ImportHelper PBC_METADATA_MAP = Hash[*%w( Type type )] PBC_REQUEST_MAP = Hash[*%w( Request\ Type type_name Control\ Code pbc_control_code Control\ Description pbc_...
Ruby
# Handle unincorporated design views here class DesignController < ApplicationController include ApplicationHelper layout 'dashboard' before_filter :require_design_feature # Render the requested partial under 'design/templates' def templates template_name = params[:name] respond_to do |format| ...
Ruby
class CategorizationsController < BaseMappingsController # access_control :acl do # allow :superuser # end def index @objects = Categorization if params[:object_id].present? @objects = @objects.where( :categorizable_type => params[:object_type], :categorizable_id => params[:object...
Ruby
class PopulationSamplesController < BaseObjectsController # access_control :acl do # allow :superuser # end layout 'dashboard' no_base_action :index, :show, :tooltip private def object_path flow_pbc_list_path(@population_sample.response.request.pbc_list_id) end def post_destroy_path ...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Handle Org Groups class OrgGroupsController < BusinessObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :index do # allow :re...
Ruby
class UserSessionsController < ApplicationController skip_before_filter :require_user, :except => :destroy #before_filter :require_no_user, :only => [:new, :create] #before_filter :require_user, :only => :destroy layout 'welcome' access_control :acl do allow all end def login if current_us...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2011 # License:: Apache 2.0 # Handle evidence collection class EvidenceController < ApplicationController include GdataHelper include DocumentHelper include EvidenceHelper include ApplicationHelper # access_control :acl do # ...
Ruby
class WelcomeController < ApplicationController skip_before_filter :require_user access_control :acl do allow all end def index session[:return_to] = login_dispatch_path if current_user redirect_to programs_dash_path end end def login_dispatch if current_user.nil? redirect...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Programs overview class ProgramsDashController < ApplicationController include DashboardHelper # access_control :acl do # allow logged_in # end layout 'dashboard' def index @programs = allo...
Ruby
class ObjectPeopleController < BaseMappingsController # access_control :acl do # allow :superuser # # actions :index do # allow :read, :read_object_person # end # # actions :create do # allow :create, :create_object_person # end # # actions :list_edit, :create do # allow :update, :upd...
Ruby
class MeetingsController < BaseObjectsController # access_control :acl do # allow :superuser # end layout 'dashboard' no_base_action :index, :show, :tooltip private def object_path flow_pbc_list_path(@meeting.response.request.pbc_list_id) end def post_destroy_path flow_pbc_list_...
Ruby
# Handle projects class ProjectsController < BusinessObjectsController access_control :acl do # FIXME: Implement real authorization allow :superuser actions :new, :create do allow :create, :create_project end actions :edit, :update do allow :update, :update_project, :of => :project...
Ruby
# Handle Control Assessments class ControlAssessmentsController < BaseObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :index do # allow :read, :read_control_assessment # end # # actions :new, :create do # allow :create, :crea...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 require 'csv' # HandleSystems class SystemsController < BaseObjectsController # access_control :acl do # allow :superuser # # actions :new, :create, :import do # allow :create, :create_system # ...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Handle Transactions class TransactionsController < BaseObjectsController # access_control :acl do # allow :superuser # end layout 'dashboard' no_base_action :index, :show, :tooltip private ...
Ruby
class BaseObjectsController < ApplicationController include ApplicationHelper before_filter :load_object, :only => [ :show, :edit, :update, :delete, :destroy, :tooltip] def index object_set = model_class if params[:s].present? if object_set.respond_to?(:fulltext_search) object_set = ob...
Ruby
# Handle Responses class ResponsesController < BaseObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :index do # allow :read, :read_response # end # # actions :new, :create do # allow :create, :create_response # end # # a...
Ruby
# Handle markets class DataAssetsController < BusinessObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :new, :create do # allow :create, :create_data_asset # end # # actions :edit, :update do # allow :update, :update_data_asse...
Ruby
class RiskRiskyAttributesController < BaseMappingsController # access_control :acl do # allow :superuser # end before_filter :check_risk_authorization def index @objects = RiskRiskyAttribute if params[:risk_id].present? @objects = @objects.where(:risk_id => params[:risk_id]) end if p...
Ruby
class ProgramDirectivesController < BaseMappingsController # access_control :acl do # allow :superuser # end def index @objects = ProgramDirective if params[:program_id].present? @objects = @objects.where(:program_id => params[:program_id]) if params[:directive_meta_kind].present? @...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Handle Documents class DocumentsController < BaseObjectsController # access_control :acl do # allow :superuser # # actions :create, :new do # allow :create, :create_document # end # # acti...
Ruby
class SystemControlsController < BaseMappingsController # access_control :acl do # allow :superuser # end def index @objects = SystemControl if params[:system_id].present? @objects = @objects.where(:system_id => params[:system_id]) end if params[:control_id].present? @objects = @obj...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 class PeopleController < BaseObjectsController # access_control :acl do # allow :superuser # # actions :index do # allow :read, :read_person # end # # actions :new, :create do # allow :...
Ruby
class RelationshipsController < BaseMappingsController # access_control :acl do # allow :superuser # allow :read, :read_relationship, :to => [:related_objects] # end def index wants_risk = false if is_risky_type?(params[:object_type]) || is_risky_type?(params[:related_model]) wants_risk = true...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 class CyclesController < BaseObjectsController # access_control :acl do # allow :superuser # # actions :new, :create do # allow :create, :create_cycle # end # # actions :show, :tooltip do # ...
Ruby
class BaseMappingsController < ApplicationController include ApplicationHelper def create if params[:items].present? errors, objects = {}, {} ActiveRecord::Base.transaction do params[:items].keys.each do |id| item_errors, item_object = create_or_update_object(params[:items][id]) ...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 require 'csv' class DirectivesController < BaseObjectsController # FIXME: Decide if the :section, controls, etc. # methods should be moved, and what access controls they # need. before_filter :load_di...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2011 # License:: Apache 2.0 # Handle Google Docs integration class DocumentController < ApplicationController include GdataHelper include DocumentHelper # access_control :acl do # allow :superuser # # actions :index do # ...
Ruby
# Handle Requests class RequestsController < BaseObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :index do # allow :read, :read_request # end # # actions :new, :create do # allow :create, :create_request # end # # actio...
Ruby
# Author:: Daniel Ring (mailto:danring+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 class CategoriesController < BaseObjectsController # access_control :acl do # allow :superuser # end layout 'dashboard' no_base_action :tooltip def index @categories = Category if params[...
Ruby
# Handle RiskyAttributes class RiskyAttributesController < BaseObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :index do # allow :read, :read_risky_attribute # end # # actions :new, :create do # allow :create, :create_risky_a...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2011 # License:: Apache 2.0 # This class is the base for all controllers used in this app #require 'dm-rails/middleware/identity_map' class ApplicationController < ActionController::Base include ApplicationHelper include Authorizati...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Browse sections class SectionsController < BaseObjectsController include DirectivesHelper cache_sweeper :section_sweeper, :only => [:create, :update, :destroy] # access_control :acl do # allow :sup...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Handle markets class MarketsController < BusinessObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :new, :create do # allow :...
Ruby
class BusinessObjectsController < BaseObjectsController include BusinessObjectsHelper end
Ruby
class MappingController < ApplicationController include ControlsHelper layout 'dashboard' respond_to :html, :json cache_sweeper :section_sweeper, :only => [:map_rcontrol, :map_ccontrol, :update] cache_sweeper :control_sweeper, :only => [:map_rcontrol, :map_ccontrol] def show @program = Program.find(p...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Handle Controls class ControlsController < BaseObjectsController include ControlsHelper include AuthorizationHelper before_filter :load_control, :only => [:sections, ...
Ruby
# Handle Risks require 'csv' class RisksController < BaseObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :index do # allow :read, :read_risk # end # # actions :new, :create do # allow :create, :create_risk # end # # a...
Ruby
class SystemSystemsController < BaseMappingsController # access_control :acl do # allow :superuser # end def index @objects = SystemSystem if params[:parent_id].present? @objects = @objects.where(:parent_id => params[:parent_id]) end render :json => @objects, :include => :child end p...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Admin dashboard class AdminDashController < ApplicationController # access_control :acl do # allow :superuser # end before_filter :check_admin_authorization layout 'dashboard' def index ...
Ruby
# Author:: Slobodan Kovacevic (mailto:basti@reciprocitynow.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 class OptionsController < BaseObjectsController # access_control :acl do # allow :superuser # end layout 'dashboard' def index @options = Option.all if params[:s].present? @op...
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' CmsRails::Application.load_tasks if Rails.env.development? || Rails.env.test? requ...
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
# Uncomment or put the following in Gemfile.local # source 'http://rubygems.org' if File.exist? 'Gemfile.local' instance_eval(Bundler.read_file('Gemfile.local'), 'Gemfile.local', 1) end RAILS_VERSION = '= 3.2.13' # Fulltext search gem 'thinking-sphinx', '~> 2.0.14' gem 'remotipart' #gem 'gdata-ruby-util', '1.1.2...
Ruby
class CreatePrograms < ActiveRecord::Migration def change create_table :programs do |t| t.string :slug t.string :title t.text :description t.string :url t.references :modified_by t.datetime :start_date t.datetime :stop_date t.timestamps end end end
Ruby
class CreateCategories < ActiveRecord::Migration def change create_table :categories do |t| t.string :name t.integer :parent_id t.integer :lft t.integer :rgt t.integer :scope_id t.integer :depth t.timestamps end create_table :categorizations do |t| t.refer...
Ruby
class CreateResponses < ActiveRecord::Migration def change create_table :responses do |t| t.references :request t.references :system t.string :status t.references :modified_by t.timestamps end end end
Ruby
class EnsureRequestTypeIdIsNotNil < ActiveRecord::Migration def up Request.all.reject(&:type_name).each{ |r| r.update_attribute(:type_id, 1) } end def down end end
Ruby
class ChangePolymorphicTypesFromLocationToFacility < ActiveRecord::Migration def up ObjectPerson.where(:personable_type => 'Location').all.each do |o| o.update_attribute(:personable_type, 'Facility') end ObjectDocument.where(:documentable_type => 'Location').all.each do |o| o.update_attribute(...
Ruby
class UpdateBaseRelationshipTypes < ActiveRecord::Migration def up RelationshipType.reset_column_information new_relationship_types = [ # Relationship types are in alphabetical order! { :relationship_type => 'location_is_dependent_on_location', :description => "Locations can be de...
Ruby
class CreateRelationshipTypes < ActiveRecord::Migration def change create_table :relationship_types, :id => false do |t| t.string :relationship_type t.string :description t.string :forward_short_description t.string :backward_short_description t.timestamps end add_index...
Ruby
class ChangePolymorphicTypesToProgramFromDirective < ActiveRecord::Migration RELATIONSHIP_TYPE_NAME_CHANGES = [ [:directive_applies_to_data_asset, :program_applies_to_data_asset], [:directive_applies_to_facility, :program_applies_to_facility], [:directive_applies_to_market, :program_applies_to_marke...
Ruby
class CreateObjectDocuments < ActiveRecord::Migration class BizProcessDocument < ActiveRecord::Base end class DocumentSystem < ActiveRecord::Base end class DocumentSystemControl < ActiveRecord::Base end def change create_table :object_documents do |t| t.string :role t.text :notes t....
Ruby