Make database offline mode work

This commit is contained in:
Tom Hughes 2010-06-15 10:07:39 +01:00
parent f980e7e4a6
commit 8af14faa49
8 changed files with 106 additions and 84 deletions

View file

@ -51,7 +51,9 @@ Rails::Initializer.run do |config|
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "aws-s3", :lib => "aws/s3"
unless OSM_STATUS == :database_offline
config.gem 'composite_primary_keys', :version => '2.2.2'
end
config.gem 'libxml-ruby', :version => '>= 1.1.1', :lib => 'libxml'
config.gem 'rmagick', :lib => 'RMagick'
config.gem 'oauth', :version => '>= 0.3.6'
@ -86,7 +88,9 @@ Rails::Initializer.run do |config|
# 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 with 'rake db:sessions:create')
unless OSM_STATUS == :database_offline
config.action_controller.session_store = :sql_session_store
end
# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,

View file

@ -1,3 +1,4 @@
if defined?(ActionRecord::ConnectionAdaptors::AbstractAdaptor)
module ActiveRecord
module ConnectionAdapters
class AbstractAdapter
@ -24,3 +25,4 @@ module ActiveRecord
end
end
end
end

View file

@ -1,3 +1,4 @@
if defined?(ActionRecord::ConnectionAdaptors::PostgreSQLAdaptor)
module ActiveRecord
module ConnectionAdapters
class PostgreSQLAdapter
@ -53,3 +54,4 @@ module ActiveRecord
end
end
end
end

View file

@ -1,3 +1,4 @@
if defined?(ActionRecord::ConnectionAdaptors::QueryCache)
module ActiveRecord
module ConnectionAdapters
module QueryCache
@ -8,3 +9,4 @@ module ActiveRecord
end
end
end
end

View file

@ -4,4 +4,6 @@ adapter = Rails.configuration.database_configuration[environment]["adapter"]
session_class = adapter + "_session"
# Configure SqlSessionStore
unless OSM_STATUS == :database_offline
SqlSessionStore.session_class = session_class.camelize.constantize
end

View file

@ -1,2 +1,5 @@
require 'deadlock_retry'
if defined?(ActionRecord::Base)
ActiveRecord::Base.send :include, DeadlockRetry
end

View file

@ -8,6 +8,11 @@ require 'file_column_helper'
require 'validations'
require 'test_case'
if defined?(ActionRecord::Base)
ActiveRecord::Base.send(:include, FileColumn)
ActionView::Base.send(:include, FileColumnHelper)
ActiveRecord::Base.send(:include, FileColumn::Validations)
end
if defined?(ActionView::Base)
ActionView::Base.send(:include, FileColumnHelper)
end

View file

@ -1 +1,3 @@
if defined?(ActionRecord::Base)
require 'validates_email_format_of'
end