dm_preferences 0.5.6 → 1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +13 -5
- data/.gitignore +2 -0
- data/.travis.yml +2 -2
- data/{CHANGELOG.rdoc → CHANGELOG.md} +26 -15
- data/LICENSE +2 -0
- data/{README.rdoc → README.md} +144 -96
- data/Rakefile +20 -27
- data/dm_preferences.gemspec +7 -5
- data/lib/generators/{USAGE → preferences/USAGE} +0 -0
- data/lib/generators/{preferences_generator.rb → preferences/preferences_generator.rb} +0 -0
- data/lib/generators/{templates → preferences/templates}/create_preferences.rb +5 -1
- data/lib/preferences.rb +33 -10
- data/lib/preferences/engine.rb +2 -1
- data/lib/preferences/preference_definition.rb +15 -4
- data/lib/preferences/version.rb +1 -1
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/{test/app_root → spec/dummy}/app/models/car.rb +0 -0
- data/{test/app_root → spec/dummy}/app/models/employee.rb +0 -0
- data/{test/app_root → spec/dummy}/app/models/manager.rb +0 -0
- data/{test/app_root → spec/dummy}/app/models/user.rb +0 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +32 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/{test/app_root → spec/dummy}/db/migrate/001_create_users.rb +0 -0
- data/{test/app_root → spec/dummy}/db/migrate/002_create_cars.rb +0 -0
- data/{test/app_root → spec/dummy}/db/migrate/003_create_employees.rb +0 -0
- data/spec/dummy/db/migrate/004_create_preferences.rb +16 -0
- data/spec/dummy/db/schema.rb +42 -0
- data/spec/functional/preferences_spec.rb +1427 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/support/assert_queries.rb +36 -0
- data/{test → spec/support}/factory.rb +1 -1
- data/spec/unit/preference_definition_spec.rb +249 -0
- data/{test/unit/preference_test.rb → spec/unit/preference_spec.rb} +114 -122
- metadata +127 -53
- data/test/app_root/db/migrate/004_migrate_preferences_to_version_1.rb +0 -13
- data/test/functional/preferences_test.rb +0 -1387
- data/test/test_helper.rb +0 -26
- data/test/unit/preference_definition_test.rb +0 -237
data/Rakefile
CHANGED
|
@@ -1,36 +1,29 @@
|
|
|
1
|
-
require 'rubygems'
|
|
2
|
-
require 'rake'
|
|
3
|
-
require 'rake/testtask'
|
|
4
|
-
require 'rake/rdoctask'
|
|
5
|
-
|
|
6
|
-
desc 'Default: run all tests.'
|
|
7
|
-
task :default => :test
|
|
8
|
-
|
|
9
|
-
desc "Test preferences."
|
|
10
|
-
Rake::TestTask.new(:test) do |t|
|
|
11
|
-
t.libs << 'lib'
|
|
12
|
-
t.test_files = Dir['test/**/*_test.rb']
|
|
13
|
-
t.verbose = true
|
|
14
|
-
end
|
|
15
|
-
|
|
16
1
|
begin
|
|
17
|
-
require '
|
|
18
|
-
namespace :test do
|
|
19
|
-
desc "Test preferences with Rcov."
|
|
20
|
-
Rcov::RcovTask.new(:rcov) do |t|
|
|
21
|
-
t.libs << 'lib'
|
|
22
|
-
t.test_files = Dir['test/**/*_test.rb']
|
|
23
|
-
t.rcov_opts << '--exclude="^(?!lib/|app/)"'
|
|
24
|
-
t.verbose = true
|
|
25
|
-
end
|
|
26
|
-
end
|
|
2
|
+
require 'bundler/setup'
|
|
27
3
|
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
28
5
|
end
|
|
29
6
|
|
|
7
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
|
8
|
+
load 'rails/tasks/engine.rake'
|
|
9
|
+
|
|
10
|
+
Bundler::GemHelper.install_tasks
|
|
11
|
+
|
|
12
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
|
13
|
+
|
|
14
|
+
require 'rspec/core'
|
|
15
|
+
require 'rspec/core/rake_task'
|
|
16
|
+
|
|
17
|
+
desc "Run specs for Preferences"
|
|
18
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
|
19
|
+
|
|
20
|
+
task :default => :spec
|
|
21
|
+
|
|
22
|
+
require 'rdoc/task'
|
|
30
23
|
desc "Generate documentation for preferences."
|
|
31
24
|
Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
32
25
|
rdoc.rdoc_dir = 'rdoc'
|
|
33
26
|
rdoc.title = 'preferences'
|
|
34
|
-
rdoc.options << '--line-numbers' << '--inline-source' << '--main=README.
|
|
35
|
-
rdoc.rdoc_files.include('README.
|
|
27
|
+
rdoc.options << '--line-numbers' << '--inline-source' << '--main=README.md'
|
|
28
|
+
rdoc.rdoc_files.include('README.md', 'CHANGELOG.md', 'LICENSE', 'lib/**/*.rb', 'app/**/*.rb')
|
|
36
29
|
end
|
data/dm_preferences.gemspec
CHANGED
|
@@ -9,13 +9,15 @@ Gem::Specification.new do |s|
|
|
|
9
9
|
s.description = "Adds support for easily creating custom preferences for ActiveRecord models"
|
|
10
10
|
s.summary = "Custom preferences for ActiveRecord models"
|
|
11
11
|
s.homepage = 'https://github.com/digitalmoksha/preferences'
|
|
12
|
+
s.licenses = ['MIT']
|
|
12
13
|
|
|
13
14
|
s.require_paths = ["lib"]
|
|
14
15
|
s.files = `git ls-files`.split("\n")
|
|
15
|
-
s.test_files =
|
|
16
|
+
s.test_files = Dir["spec/**/*"]
|
|
16
17
|
s.rdoc_options = %w(--line-numbers --inline-source --title preferences --main README.rdoc)
|
|
17
|
-
s.extra_rdoc_files = %w(README.
|
|
18
|
+
s.extra_rdoc_files = %w(README.md CHANGELOG.md LICENSE)
|
|
18
19
|
|
|
19
|
-
s.add_development_dependency
|
|
20
|
-
s.add_development_dependency
|
|
21
|
-
|
|
20
|
+
s.add_development_dependency "rails", "~> 4.2"
|
|
21
|
+
s.add_development_dependency "sqlite3", '~> 0'
|
|
22
|
+
s.add_development_dependency 'rspec-rails', '~> 3.0'
|
|
23
|
+
end
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class CreatePreferences < ActiveRecord::Migration
|
|
2
|
-
def
|
|
2
|
+
def up
|
|
3
3
|
create_table :preferences do |t|
|
|
4
4
|
t.string :name, :null => false
|
|
5
5
|
t.references :owner, :polymorphic => true, :null => false
|
|
@@ -9,4 +9,8 @@ class CreatePreferences < ActiveRecord::Migration
|
|
|
9
9
|
end
|
|
10
10
|
add_index :preferences, [:owner_id, :owner_type, :name, :group_id, :group_type], :unique => true, :name => 'index_preferences_on_owner_and_name_and_preference'
|
|
11
11
|
end
|
|
12
|
+
|
|
13
|
+
def down
|
|
14
|
+
drop_table :preferences
|
|
15
|
+
end
|
|
12
16
|
end
|
data/lib/preferences.rb
CHANGED
|
@@ -46,6 +46,7 @@ require 'preferences/preference_definition'
|
|
|
46
46
|
# u.valid? # => true
|
|
47
47
|
module Preferences
|
|
48
48
|
module MacroMethods
|
|
49
|
+
|
|
49
50
|
# Defines a new preference for all records in the model. By default,
|
|
50
51
|
# preferences are assumed to have a boolean data type, so all values will
|
|
51
52
|
# be typecasted to true/false based on ActiveRecord rules.
|
|
@@ -156,7 +157,7 @@ module Preferences
|
|
|
156
157
|
class_attribute :preference_definitions
|
|
157
158
|
self.preference_definitions = {}
|
|
158
159
|
|
|
159
|
-
has_many :stored_preferences, :as => :owner, :class_name => 'Preference', :dependent => :
|
|
160
|
+
has_many :stored_preferences, :as => :owner, :class_name => 'Preference', :dependent => :delete_all
|
|
160
161
|
|
|
161
162
|
after_save :update_preferences
|
|
162
163
|
|
|
@@ -259,12 +260,13 @@ module Preferences
|
|
|
259
260
|
|
|
260
261
|
# Since each preference is a different record, they need their own
|
|
261
262
|
# join so that the proper conditions can be set
|
|
262
|
-
joins << "LEFT JOIN preferences AS #{table} ON #{table}.owner_id = #{table_name}.#{primary_key} AND " +
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
263
|
+
joins << "LEFT JOIN preferences AS #{table} ON #{table}.owner_id = #{table_name}.#{primary_key} AND " +
|
|
264
|
+
sanitize_sql_hash_for_conditions(
|
|
265
|
+
"#{table}.owner_type" => base_class.name.to_s,
|
|
266
|
+
"#{table}.group_id" => group_id,
|
|
267
|
+
"#{table}.group_type" => group_type,
|
|
268
|
+
"#{table}.name" => preference
|
|
269
|
+
)
|
|
268
270
|
|
|
269
271
|
if inverse
|
|
270
272
|
statements << "#{table}.id IS NOT NULL AND #{table}.value " + (value.nil? ? ' IS NOT NULL' : ' != ?') + (!is_default ? " OR #{table}.id IS NULL" : '')
|
|
@@ -275,8 +277,22 @@ module Preferences
|
|
|
275
277
|
end
|
|
276
278
|
|
|
277
279
|
sql = statements.map! {|statement| "(#{statement})"} * ' AND '
|
|
278
|
-
|
|
280
|
+
joins(joins).where(values.unshift(sql))
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# this function is deprecated in 4.2 and to be removed in 5.0.
|
|
284
|
+
# but it's useful, particularly how it can handle conditions that are nil.
|
|
285
|
+
# so keep it for now.
|
|
286
|
+
def sanitize_sql_hash_for_conditions(attrs, default_table_name = self.table_name)
|
|
287
|
+
attrs = ActiveRecord::PredicateBuilder.resolve_column_aliases self, attrs
|
|
288
|
+
attrs = expand_hash_conditions_for_aggregates(attrs)
|
|
289
|
+
|
|
290
|
+
table = Arel::Table.new(table_name, arel_engine).alias(default_table_name)
|
|
291
|
+
ActiveRecord::PredicateBuilder.build_from_hash(self, attrs, table).map { |b|
|
|
292
|
+
connection.visitor.compile b
|
|
293
|
+
}.join(' AND ')
|
|
279
294
|
end
|
|
295
|
+
|
|
280
296
|
end
|
|
281
297
|
|
|
282
298
|
module InstanceMethods
|
|
@@ -498,6 +514,7 @@ module Preferences
|
|
|
498
514
|
end
|
|
499
515
|
|
|
500
516
|
private
|
|
517
|
+
|
|
501
518
|
# Asserts that the given name is a valid preference in this model. If it
|
|
502
519
|
# is not, then an ArgumentError exception is raised.
|
|
503
520
|
def assert_valid_preference(name)
|
|
@@ -606,13 +623,19 @@ module Preferences
|
|
|
606
623
|
def find_preferences(attributes)
|
|
607
624
|
if stored_preferences.loaded?
|
|
608
625
|
stored_preferences.select do |preference|
|
|
609
|
-
attributes.all?
|
|
626
|
+
attributes.all? do |attribute, value|
|
|
627
|
+
if value.is_a?(Array)
|
|
628
|
+
value.include?(preference[attribute])
|
|
629
|
+
else
|
|
630
|
+
preference[attribute] == value
|
|
631
|
+
end
|
|
632
|
+
end
|
|
610
633
|
end
|
|
611
634
|
else
|
|
612
635
|
stored_preferences.where(attributes)
|
|
613
636
|
end
|
|
614
637
|
end
|
|
615
|
-
|
|
638
|
+
|
|
616
639
|
# Was removed from Rails 4, so inlne it here
|
|
617
640
|
def convert_number_column_value(value)
|
|
618
641
|
case value
|
data/lib/preferences/engine.rb
CHANGED
|
@@ -10,9 +10,18 @@ module Preferences
|
|
|
10
10
|
|
|
11
11
|
@type = args.first ? args.first.to_sym : :boolean
|
|
12
12
|
|
|
13
|
+
case @type
|
|
14
|
+
when :any
|
|
15
|
+
@klass = "ActiveRecord::Type::Value".constantize.new
|
|
16
|
+
when :datetime
|
|
17
|
+
@klass = "ActiveRecord::Type::DateTime".constantize.new
|
|
18
|
+
else
|
|
19
|
+
@klass = "ActiveRecord::Type::#{@type.to_s.classify}".constantize.new
|
|
20
|
+
end
|
|
21
|
+
|
|
13
22
|
# Create a column that will be responsible for typecasting
|
|
14
|
-
@column = ActiveRecord::ConnectionAdapters::Column.new(name.to_s, options[:default], @
|
|
15
|
-
|
|
23
|
+
@column = ActiveRecord::ConnectionAdapters::Column.new(name.to_s, options[:default], @klass)
|
|
24
|
+
|
|
16
25
|
@group_defaults = (options[:group_defaults] || {}).inject({}) do |defaults, (group, default)|
|
|
17
26
|
defaults[group.is_a?(Symbol) ? group.to_s : group] = type_cast(default)
|
|
18
27
|
defaults
|
|
@@ -27,7 +36,7 @@ module Preferences
|
|
|
27
36
|
# The default value to use for the preference in case none have been
|
|
28
37
|
# previously defined
|
|
29
38
|
def default_value(group = nil)
|
|
30
|
-
@group_defaults.include?(group) ? @group_defaults[group] : @column.default
|
|
39
|
+
@group_defaults.include?(group) ? @group_defaults[group] : type_cast(@column.default)
|
|
31
40
|
end
|
|
32
41
|
|
|
33
42
|
# Determines whether column backing this preference stores numberic values
|
|
@@ -39,7 +48,9 @@ module Preferences
|
|
|
39
48
|
# This uses ActiveRecord's typecast functionality so the same rules for
|
|
40
49
|
# typecasting a model's columns apply here.
|
|
41
50
|
def type_cast(value)
|
|
42
|
-
@type == :
|
|
51
|
+
return 1 if @type == :integer && value == true
|
|
52
|
+
return 0 if @type == :integer && value == false
|
|
53
|
+
@type == :any ? value : @column.type_cast_from_database(value)
|
|
43
54
|
end
|
|
44
55
|
|
|
45
56
|
# Typecasts the value to true/false depending on the type of preference
|
data/lib/preferences/version.rb
CHANGED
data/spec/dummy/Rakefile
ADDED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/spec/dummy/bin/rake
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'pathname'
|
|
3
|
+
|
|
4
|
+
# path to your application root.
|
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
|
6
|
+
|
|
7
|
+
Dir.chdir APP_ROOT do
|
|
8
|
+
# This script is a starting point to setup your application.
|
|
9
|
+
# Add necessary setup steps to this file:
|
|
10
|
+
|
|
11
|
+
puts "== Installing dependencies =="
|
|
12
|
+
system "gem install bundler --conservative"
|
|
13
|
+
system "bundle check || bundle install"
|
|
14
|
+
|
|
15
|
+
# puts "\n== Copying sample files =="
|
|
16
|
+
# unless File.exist?("config/database.yml")
|
|
17
|
+
# system "cp config/database.yml.sample config/database.yml"
|
|
18
|
+
# end
|
|
19
|
+
|
|
20
|
+
puts "\n== Preparing database =="
|
|
21
|
+
system "bin/rake db:setup"
|
|
22
|
+
|
|
23
|
+
puts "\n== Removing old logs and tempfiles =="
|
|
24
|
+
system "rm -f log/*"
|
|
25
|
+
system "rm -rf tmp/cache"
|
|
26
|
+
|
|
27
|
+
puts "\n== Restarting application server =="
|
|
28
|
+
system "touch tmp/restart.txt"
|
|
29
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
# Pick the frameworks you want:
|
|
4
|
+
require "active_record/railtie"
|
|
5
|
+
require "action_controller/railtie"
|
|
6
|
+
require "action_mailer/railtie"
|
|
7
|
+
require "action_view/railtie"
|
|
8
|
+
require "sprockets/railtie"
|
|
9
|
+
# require "rails/test_unit/railtie"
|
|
10
|
+
|
|
11
|
+
Bundler.require(*Rails.groups)
|
|
12
|
+
require "preferences"
|
|
13
|
+
|
|
14
|
+
module Dummy
|
|
15
|
+
class Application < Rails::Application
|
|
16
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
17
|
+
# Application configuration should go into files in config/initializers
|
|
18
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
19
|
+
|
|
20
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
21
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
22
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
|
23
|
+
|
|
24
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
25
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
26
|
+
# config.i18n.default_locale = :de
|
|
27
|
+
|
|
28
|
+
# Do not swallow errors in after_commit/after_rollback callbacks.
|
|
29
|
+
config.active_record.raise_in_transactional_callbacks = true
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# SQLite version 3.x
|
|
2
|
+
# gem install sqlite3
|
|
3
|
+
#
|
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
|
5
|
+
# gem 'sqlite3'
|
|
6
|
+
#
|
|
7
|
+
default: &default
|
|
8
|
+
adapter: sqlite3
|
|
9
|
+
pool: 5
|
|
10
|
+
timeout: 5000
|
|
11
|
+
|
|
12
|
+
development:
|
|
13
|
+
<<: *default
|
|
14
|
+
database: db/development.sqlite3
|
|
15
|
+
|
|
16
|
+
# Warning: The database defined as "test" will be erased and
|
|
17
|
+
# re-generated from your development database when you run "rake".
|
|
18
|
+
# Do not set this db to the same as development or production.
|
|
19
|
+
test:
|
|
20
|
+
<<: *default
|
|
21
|
+
database: db/test.sqlite3
|
|
22
|
+
|
|
23
|
+
production:
|
|
24
|
+
<<: *default
|
|
25
|
+
database: db/production.sqlite3
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Rails.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
|
+
# Do not eager load code on boot.
|
|
10
|
+
config.eager_load = false
|
|
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
|
+
# Raise an error on page load if there are pending migrations.
|
|
23
|
+
config.active_record.migration_error = :page_load
|
|
24
|
+
|
|
25
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
|
26
|
+
# This option may cause significant delays in view rendering with a large
|
|
27
|
+
# number of complex assets.
|
|
28
|
+
config.assets.debug = true
|
|
29
|
+
|
|
30
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
|
31
|
+
# yet still be able to expire them through the digest params.
|
|
32
|
+
config.assets.digest = true
|
|
33
|
+
|
|
34
|
+
# Adds additional error checking when serving assets at runtime.
|
|
35
|
+
# Checks for improperly declared sprockets dependencies.
|
|
36
|
+
# Raises helpful error messages.
|
|
37
|
+
config.assets.raise_runtime_errors = true
|
|
38
|
+
|
|
39
|
+
# Raises error for missing translations
|
|
40
|
+
# config.action_view.raise_on_missing_translations = true
|
|
41
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Rails.application.configure do
|
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
|
3
|
+
|
|
4
|
+
# Code is not reloaded between requests.
|
|
5
|
+
config.cache_classes = true
|
|
6
|
+
|
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
|
8
|
+
# your application in memory, allowing both threaded web servers
|
|
9
|
+
# and those relying on copy on write to perform better.
|
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
|
11
|
+
config.eager_load = true
|
|
12
|
+
|
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
|
14
|
+
config.consider_all_requests_local = false
|
|
15
|
+
config.action_controller.perform_caching = true
|
|
16
|
+
|
|
17
|
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
|
18
|
+
# Add `rack-cache` to your Gemfile before enabling this.
|
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like
|
|
20
|
+
# NGINX, varnish or squid.
|
|
21
|
+
# config.action_dispatch.rack_cache = true
|
|
22
|
+
|
|
23
|
+
# Disable serving static files from the `/public` folder by default since
|
|
24
|
+
# Apache or NGINX already handles this.
|
|
25
|
+
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
|
26
|
+
|
|
27
|
+
# Compress JavaScripts and CSS.
|
|
28
|
+
config.assets.js_compressor = :uglifier
|
|
29
|
+
# config.assets.css_compressor = :sass
|
|
30
|
+
|
|
31
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
|
32
|
+
config.assets.compile = false
|
|
33
|
+
|
|
34
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
|
35
|
+
# yet still be able to expire them through the digest params.
|
|
36
|
+
config.assets.digest = true
|
|
37
|
+
|
|
38
|
+
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
|
39
|
+
|
|
40
|
+
# Specifies the header that your server uses for sending files.
|
|
41
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
|
42
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
|
43
|
+
|
|
44
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
|
45
|
+
# config.force_ssl = true
|
|
46
|
+
|
|
47
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
|
48
|
+
# when problems arise.
|
|
49
|
+
config.log_level = :debug
|
|
50
|
+
|
|
51
|
+
# Prepend all log lines with the following tags.
|
|
52
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
|
53
|
+
|
|
54
|
+
# Use a different logger for distributed setups.
|
|
55
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
|
56
|
+
|
|
57
|
+
# Use a different cache store in production.
|
|
58
|
+
# config.cache_store = :mem_cache_store
|
|
59
|
+
|
|
60
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
|
61
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
|
62
|
+
|
|
63
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
|
64
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
|
65
|
+
# config.action_mailer.raise_delivery_errors = false
|
|
66
|
+
|
|
67
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
|
68
|
+
# the I18n.default_locale when a translation cannot be found).
|
|
69
|
+
config.i18n.fallbacks = true
|
|
70
|
+
|
|
71
|
+
# Send deprecation notices to registered listeners.
|
|
72
|
+
config.active_support.deprecation = :notify
|
|
73
|
+
|
|
74
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
|
75
|
+
config.log_formatter = ::Logger::Formatter.new
|
|
76
|
+
|
|
77
|
+
# Do not dump schema after migrations.
|
|
78
|
+
config.active_record.dump_schema_after_migration = false
|
|
79
|
+
end
|