storey 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/README.md +83 -0
- data/Rakefile +7 -0
- data/lib/storey/duplicator.rb +61 -0
- data/lib/storey/exceptions.rb +6 -0
- data/lib/storey/migrator.rb +28 -0
- data/lib/storey/railtie.rb +47 -0
- data/lib/storey/version.rb +3 -0
- data/lib/storey.rb +161 -0
- data/lib/tasks/storey.rake +57 -0
- data/spec/config/database.yml.sample +6 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/company.rb +2 -0
- data/spec/dummy/app/models/fake.rb +2 -0
- data/spec/dummy/app/models/post.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml.sample +6 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20120115060713_create_companies.rb +8 -0
- data/spec/dummy/db/migrate/20120115060728_create_posts.rb +8 -0
- data/spec/dummy/db/schema.rb +25 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/fixtures/.gitkeep +0 -0
- data/spec/migrator_spec.rb +63 -0
- data/spec/spec_helper.rb +47 -0
- data/spec/storey/configuration_spec.rb +13 -0
- data/spec/storey/create_spec.rb +87 -0
- data/spec/storey/drop_spec.rb +31 -0
- data/spec/storey/duplicate_spec.rb +49 -0
- data/spec/storey/excluded_models_spec.rb +15 -0
- data/spec/storey/schema_spec.rb +31 -0
- data/spec/storey/schemas_spec.rb +51 -0
- data/spec/storey/switch_spec.rb +102 -0
- data/spec/tasks/storey_rake_spec.rb +106 -0
- data/storey.gemspec +27 -0
- metadata +204 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# Storey
|
2
|
+
|
3
|
+
Storey is used to manage multiple schemas in your multi-tenant Rails application.
|
4
|
+
|
5
|
+
Heavily inspired by the Apartment gem, Storey simplifies the implementation of managing a multi-tenant application. This simplifies things by doing away with the other implementations that Apartment has - like MysqlAdapter and managing multiple databases (instead of managing multiple schemas) which complicated development and testing.
|
6
|
+
|
7
|
+
# Configuration
|
8
|
+
|
9
|
+
Typically set in an initializer: config/initializer/storey.rb
|
10
|
+
|
11
|
+
# Defines the tables that should stay available to all (ie in the public schema)
|
12
|
+
Storey.excluded_tables = %w(users companies)
|
13
|
+
|
14
|
+
# If set, all schemas are created with the suffix.
|
15
|
+
# Used for obscuring the schema name - which is important when performing schema duplication.
|
16
|
+
# Storey.suffix = "_suffix"
|
17
|
+
|
18
|
+
# Methods
|
19
|
+
|
20
|
+
## schemas
|
21
|
+
|
22
|
+
Returns all schemas except postgres' schemas.
|
23
|
+
|
24
|
+
Accepts options:
|
25
|
+
|
26
|
+
:exclude_public => true
|
27
|
+
|
28
|
+
Usage:
|
29
|
+
|
30
|
+
Storey.schemas
|
31
|
+
Storey.schemas(:exclude_public => true)
|
32
|
+
|
33
|
+
## create
|
34
|
+
|
35
|
+
Accepts:
|
36
|
+
|
37
|
+
String - name of schema
|
38
|
+
|
39
|
+
Usage:
|
40
|
+
|
41
|
+
Storey.create "schema_name"
|
42
|
+
|
43
|
+
## drop
|
44
|
+
|
45
|
+
Accepts
|
46
|
+
|
47
|
+
String - name of schema
|
48
|
+
|
49
|
+
Usage:
|
50
|
+
|
51
|
+
Storey.drop "schema_name"
|
52
|
+
|
53
|
+
## switch
|
54
|
+
|
55
|
+
Accepts
|
56
|
+
|
57
|
+
String - optional - schema name
|
58
|
+
Block - optional
|
59
|
+
|
60
|
+
If a block is passed, Storey will execute the block in the specified schema name. Then, it will switch back to the schema it was previously in.
|
61
|
+
|
62
|
+
Usage:
|
63
|
+
|
64
|
+
Storey.switch "some_other_schema"
|
65
|
+
Post.create "My new post"
|
66
|
+
Storey.switch # switch back to the original schema
|
67
|
+
|
68
|
+
Storey.switch "some_other_schema" do
|
69
|
+
Post.create "My new post"
|
70
|
+
end
|
71
|
+
|
72
|
+
## duplicate!(origin, copy)
|
73
|
+
|
74
|
+
Accepts
|
75
|
+
|
76
|
+
origin - name of old schema to copy
|
77
|
+
copy - name of new schema
|
78
|
+
|
79
|
+
Copies a schema with all data under a new name.
|
80
|
+
|
81
|
+
Usage:
|
82
|
+
|
83
|
+
Storey.duplicate!("original_schema", "new_schema")
|
data/Rakefile
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
class Storey::Duplicator
|
2
|
+
DUMP_PATH = File.join Rails.root, 'tmp', 'schema_dumps'
|
3
|
+
SOURCE_DUMP_PATH = File.join DUMP_PATH, 'source'
|
4
|
+
TARGET_DUMP_PATH = File.join DUMP_PATH, 'target'
|
5
|
+
|
6
|
+
attr_accessor :source_schema, :target_schema, :source_file, :target_file
|
7
|
+
|
8
|
+
def initialize(from_schema, to_schema)
|
9
|
+
self.source_schema = Storey.suffixify from_schema
|
10
|
+
self.target_schema = Storey.suffixify to_schema
|
11
|
+
self.source_file = File.join SOURCE_DUMP_PATH, "#{Time.now.to_i}_#{self.source_schema}.sql"
|
12
|
+
self.target_file = File.join TARGET_DUMP_PATH, "#{Time.now.to_i}_#{self.target_schema}.sql"
|
13
|
+
end
|
14
|
+
|
15
|
+
def perform!
|
16
|
+
dump_schema
|
17
|
+
replace_occurances
|
18
|
+
load_schema
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def dump_schema(options={})
|
24
|
+
ENV['PGPASSWORD'] = Storey.database_config[:password]
|
25
|
+
prepare_schema_dump_directories
|
26
|
+
|
27
|
+
options[:host] ||= Storey.database_config[:host] unless Storey.database_config[:host].blank?
|
28
|
+
options[:username] ||= Storey.database_config[:username]
|
29
|
+
options[:file] ||= self.source_file
|
30
|
+
options[:schema] ||= self.source_schema
|
31
|
+
|
32
|
+
switches = options.map { |k, v| "--#{k}=#{v}" }.join(" ")
|
33
|
+
|
34
|
+
`pg_dump #{switches} #{Storey.database_config[:database]}`
|
35
|
+
end
|
36
|
+
|
37
|
+
def prepare_schema_dump_directories
|
38
|
+
[SOURCE_DUMP_PATH, TARGET_DUMP_PATH].each { |d| FileUtils.mkdir_p(d) }
|
39
|
+
end
|
40
|
+
|
41
|
+
def load_schema(options={})
|
42
|
+
options[:host] ||= Storey.database_config[:host] unless Storey.database_config[:host].blank?
|
43
|
+
options[:dbname] ||= Storey.database_config[:database]
|
44
|
+
options[:username] ||= Storey.database_config[:username]
|
45
|
+
options[:file] ||= self.target_file
|
46
|
+
|
47
|
+
switches = options.map { |k, v| "--#{k}=#{v}" }.join(" ")
|
48
|
+
|
49
|
+
`psql #{switches}`
|
50
|
+
ENV['PGPASSWORD'] = nil
|
51
|
+
end
|
52
|
+
|
53
|
+
def replace_occurances
|
54
|
+
File.open(self.source_file, 'r') do |file|
|
55
|
+
file.each_line do |line|
|
56
|
+
new_line = line.gsub(/#{self.source_schema}/, self.target_schema)
|
57
|
+
File.open(self.target_file, 'a') {|tf| tf.puts new_line}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Storey::Migrator
|
2
|
+
extend self
|
3
|
+
|
4
|
+
def migrate(schema)
|
5
|
+
Storey.switch schema do
|
6
|
+
ActiveRecord::Migrator.migrate ActiveRecord::Migrator.migrations_path
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def run(direction, schema, version)
|
11
|
+
Storey.switch schema do
|
12
|
+
ActiveRecord::Migrator.run(
|
13
|
+
direction,
|
14
|
+
ActiveRecord::Migrator.migrations_path,
|
15
|
+
version
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def rollback(schema, step=1)
|
21
|
+
Storey.switch schema do
|
22
|
+
ActiveRecord::Migrator.rollback(
|
23
|
+
ActiveRecord::Migrator.migrations_path,
|
24
|
+
step
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#require 'rails'
|
2
|
+
class Storey::Railtie < Rails::Railtie
|
3
|
+
#
|
4
|
+
# Set up our default config options
|
5
|
+
# Do this before the app initializers run so we don't override custom settings
|
6
|
+
#
|
7
|
+
#config.before_initialize do
|
8
|
+
#Storey.configure do |config|
|
9
|
+
#config.excluded_models = []
|
10
|
+
#config.use_postgres_schemas = true
|
11
|
+
#config.database_names = []
|
12
|
+
#config.seed_after_create = false
|
13
|
+
#config.prepend_environment = true
|
14
|
+
#end
|
15
|
+
#end
|
16
|
+
|
17
|
+
# @bradrobertson's note in Apartment:
|
18
|
+
# Hook into ActionDispatch::Reloader to ensure Storey is properly initialized
|
19
|
+
# Note that this doens't entirely work as expected in Development, because this is called before classes are reloaded
|
20
|
+
# See the above middleware/console declarations below to help with this. Hope to fix that soon.
|
21
|
+
config.to_prepare do
|
22
|
+
Storey.init
|
23
|
+
end
|
24
|
+
|
25
|
+
# Load Storey's rake tasks
|
26
|
+
rake_tasks do
|
27
|
+
load 'tasks/storey.rake'
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# The following initializers are a workaround to the fact that I can't properly hook into the rails reloader
|
32
|
+
# Note this is technically valid for any environment where cache_classes is false, for us, it's just development
|
33
|
+
#
|
34
|
+
#if Rails.env.development?
|
35
|
+
|
36
|
+
# Storey::Reloader is middleware to initialize things properly on each request to dev
|
37
|
+
#initializer 'storey.init' do |app|
|
38
|
+
#app.config.middleware.use "Storey::Reloader"
|
39
|
+
#end
|
40
|
+
|
41
|
+
# Overrides reload! to also call Storey::Database.init as well so that the reloaded classes have the proper table_names
|
42
|
+
#console do
|
43
|
+
#require 'storey/console'
|
44
|
+
#end
|
45
|
+
|
46
|
+
#end
|
47
|
+
end
|
data/lib/storey.rb
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
require "storey/version"
|
2
|
+
require "rails/all"
|
3
|
+
require "active_support/core_ext/module" # so we can use mattr_accessor
|
4
|
+
require 'storey/railtie' if defined?(Rails)
|
5
|
+
require 'storey/exceptions'
|
6
|
+
require 'storey/migrator'
|
7
|
+
|
8
|
+
module Storey
|
9
|
+
extend self
|
10
|
+
|
11
|
+
autoload :Duplicator, 'storey/duplicator'
|
12
|
+
|
13
|
+
mattr_accessor :suffix, :default_search_path
|
14
|
+
mattr_reader :excluded_models
|
15
|
+
|
16
|
+
def init
|
17
|
+
@@default_search_path = schema
|
18
|
+
self.excluded_models ||= []
|
19
|
+
process_excluded_models
|
20
|
+
end
|
21
|
+
|
22
|
+
def excluded_models=(array)
|
23
|
+
@@excluded_models = array
|
24
|
+
process_excluded_models
|
25
|
+
end
|
26
|
+
|
27
|
+
def schema(options={})
|
28
|
+
options[:suffix] ||= false
|
29
|
+
|
30
|
+
name = ActiveRecord::Base.connection.schema_search_path
|
31
|
+
|
32
|
+
if options[:suffix]
|
33
|
+
name
|
34
|
+
else
|
35
|
+
unsuffixify name
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def create(name, options={}, &block)
|
40
|
+
fail ArgumentError, "Must pass in a valid schema name" if name.blank?
|
41
|
+
|
42
|
+
options[:load_database_schema] = true unless options.has_key?(:load_database_schema)
|
43
|
+
|
44
|
+
name = suffixify(name)
|
45
|
+
ActiveRecord::Base.connection.execute "CREATE SCHEMA #{name}"
|
46
|
+
switch name do
|
47
|
+
load_database_schema if options[:load_database_schema] == true
|
48
|
+
block.call if block_given?
|
49
|
+
end
|
50
|
+
rescue ActiveRecord::StatementInvalid => e
|
51
|
+
if e.to_s =~ /schema ".+" already exists/
|
52
|
+
fail Storey::SchemaExists, %{The schema "#{name}" already exists.}
|
53
|
+
else
|
54
|
+
raise e
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def schemas(options={})
|
59
|
+
options[:suffix] ||= false
|
60
|
+
options[:public] = true unless options.has_key?(:public)
|
61
|
+
|
62
|
+
sql = "SELECT nspname FROM pg_namespace"
|
63
|
+
sql << " WHERE nspname !~ '^pg_.*'"
|
64
|
+
sql << " AND nspname != 'information_schema'"
|
65
|
+
sql << " AND nspname != 'public'" unless options[:public]
|
66
|
+
|
67
|
+
names = ActiveRecord::Base.connection.query(sql).flatten
|
68
|
+
|
69
|
+
if options[:suffix]
|
70
|
+
names
|
71
|
+
else
|
72
|
+
names = names.map {|name| unsuffixify(name)}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def drop(name)
|
77
|
+
name = suffixify name
|
78
|
+
ActiveRecord::Base.connection.execute("DROP SCHEMA #{name} CASCADE")
|
79
|
+
rescue ActiveRecord::StatementInvalid => e
|
80
|
+
raise Storey::SchemaNotFound, %{The schema "#{name}" cannot be found.}
|
81
|
+
end
|
82
|
+
|
83
|
+
def switch(name=nil, &block)
|
84
|
+
if block_given?
|
85
|
+
original_schema = schema
|
86
|
+
switch name
|
87
|
+
result = block.call
|
88
|
+
switch original_schema
|
89
|
+
result
|
90
|
+
else
|
91
|
+
reset and return if name.blank?
|
92
|
+
name = suffixify name
|
93
|
+
ActiveRecord::Base.connection.schema_search_path = name
|
94
|
+
end
|
95
|
+
rescue ActiveRecord::StatementInvalid => e
|
96
|
+
if e.to_s =~ /invalid value for parameter "search_path"/
|
97
|
+
fail Storey::SchemaNotFound, %{The schema "#{name}" cannot be found.}
|
98
|
+
else
|
99
|
+
raise e
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def reload_config!
|
104
|
+
self.excluded_models = []
|
105
|
+
self.suffix = nil
|
106
|
+
end
|
107
|
+
|
108
|
+
def database_config
|
109
|
+
Rails.configuration.database_configuration[Rails.env].with_indifferent_access
|
110
|
+
end
|
111
|
+
|
112
|
+
def duplicate!(from_schema, to_schema)
|
113
|
+
duplicator = Duplicator.new from_schema, to_schema
|
114
|
+
duplicator.perform!
|
115
|
+
end
|
116
|
+
|
117
|
+
def suffixify(name)
|
118
|
+
if Storey.suffix && !name.include?(Storey.suffix) && name != self.default_search_path
|
119
|
+
"#{name}#{Storey.suffix}"
|
120
|
+
else
|
121
|
+
name
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def unsuffixify(name)
|
126
|
+
Storey.suffix && name =~ /(\w+)#{Storey.suffix}/ ? $1 : name
|
127
|
+
end
|
128
|
+
|
129
|
+
protected
|
130
|
+
|
131
|
+
def schema_migrations
|
132
|
+
ActiveRecord::Migrator.get_all_versions
|
133
|
+
end
|
134
|
+
|
135
|
+
def reset
|
136
|
+
ActiveRecord::Base.connection.schema_search_path = self.default_search_path
|
137
|
+
end
|
138
|
+
|
139
|
+
# Loads the Rails schema.rb into the current schema
|
140
|
+
def load_database_schema
|
141
|
+
ActiveRecord::Schema.verbose = false # do not log schema load output.
|
142
|
+
load_or_abort("#{Rails.root}/db/schema.rb")
|
143
|
+
end
|
144
|
+
|
145
|
+
def load_or_abort(file)
|
146
|
+
if File.exists?(file)
|
147
|
+
load(file)
|
148
|
+
else
|
149
|
+
abort %{#{file} doesn't exist yet}
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def process_excluded_models
|
154
|
+
self.excluded_models.each do |model_name|
|
155
|
+
model_name.constantize.tap do |klass|
|
156
|
+
table_name = klass.table_name.split('.', 2).last
|
157
|
+
klass.table_name = "public.#{table_name}"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
namespace :storey do
|
2
|
+
|
3
|
+
desc "Migrate all schemas including public"
|
4
|
+
task :migrate => "db:migrate" do
|
5
|
+
Storey.schemas.each do |schema|
|
6
|
+
Storey::Migrator.migrate schema
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Rolls the schema back to the previous version (specify steps w/ STEP=n) across all schemas."
|
11
|
+
task :rollback => 'db:rollback' do
|
12
|
+
step = ENV['STEP'] ? ENV['STEP'].to_i : 1
|
13
|
+
|
14
|
+
Storey.schemas.each do |db|
|
15
|
+
puts("Rolling back #{db} database")
|
16
|
+
Storey::Migrator.rollback db, step
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
namespace :migrate do
|
21
|
+
|
22
|
+
desc 'Runs the "up" for a given migration VERSION across all schemas.'
|
23
|
+
task :up => 'db:migrate:up' do
|
24
|
+
version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil
|
25
|
+
raise 'VERSION is required' unless version
|
26
|
+
|
27
|
+
Storey.schemas.each do |schema|
|
28
|
+
puts "Migrating #{schema} schema up"
|
29
|
+
Storey::Migrator.run :up, schema, version
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'Runs the "down" for a given migration VERSION across all schemas.'
|
34
|
+
task :down => 'db:migrate:down' do
|
35
|
+
version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil
|
36
|
+
raise 'VERSION is required' unless version
|
37
|
+
|
38
|
+
Storey.schemas.each do |schema|
|
39
|
+
puts "Migrating #{schema} schema down"
|
40
|
+
Storey::Migrator.run :down, schema, version
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).'
|
45
|
+
task :redo => 'db:migrate:redo' do
|
46
|
+
if ENV['VERSION']
|
47
|
+
apartment_namespace['migrate:down'].invoke
|
48
|
+
apartment_namespace['migrate:up'].invoke
|
49
|
+
else
|
50
|
+
apartment_namespace['rollback'].invoke
|
51
|
+
apartment_namespace['migrate'].invoke
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,9 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
//= require jquery
|
8
|
+
//= require jquery_ujs
|
9
|
+
//= require_tree .
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
File without changes
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require
|
6
|
+
require "storey"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
15
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
16
|
+
|
17
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
18
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
19
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
20
|
+
|
21
|
+
# Activate observers that should always be running.
|
22
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
23
|
+
|
24
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
25
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
26
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
27
|
+
|
28
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
29
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
30
|
+
# config.i18n.default_locale = :de
|
31
|
+
|
32
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
33
|
+
config.encoding = "utf-8"
|
34
|
+
|
35
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
36
|
+
config.filter_parameters += [:password]
|
37
|
+
|
38
|
+
# Enable the asset pipeline
|
39
|
+
config.assets.enabled = true
|
40
|
+
|
41
|
+
# Version of your assets, change this if you want to expire all your assets
|
42
|
+
config.assets.version = '1.0'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Only use best-standards-support built into browsers
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
|
25
|
+
# Do not compress assets
|
26
|
+
config.assets.compress = false
|
27
|
+
|
28
|
+
# Expands the lines which load the assets
|
29
|
+
config.assets.debug = true
|
30
|
+
end
|