pose 1.3.4 → 2.0.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.
- data/README.md +11 -0
- data/Rakefile +4 -2
- data/app/models/pose/assignment.rb +34 -0
- data/app/models/pose/word.rb +24 -0
- data/db/migrate/20130308144915_pose_install.rb +18 -0
- data/lib/generators/pose/remove/templates/remove_migration.rb +3 -5
- data/lib/generators/pose/upgrade/templates/upgrade_migration.rb +9 -0
- data/lib/generators/pose/upgrade/upgrade_generator.rb +35 -0
- data/lib/pose/activerecord_base_additions.rb +5 -2
- data/lib/pose/engine.rb +5 -0
- data/lib/pose/internal_helpers.rb +13 -7
- data/lib/pose/{model_additions.rb → model_class_additions.rb} +8 -8
- data/lib/pose/railtie.rb +1 -2
- data/lib/pose/static_api.rb +5 -6
- data/lib/pose/version.rb +1 -1
- data/lib/pose.rb +5 -7
- data/lib/tasks/pose_tasks.rake +27 -29
- data/spec/dummy/Rakefile +7 -0
- data/spec/{support/models.rb → dummy/app/models/posable_one.rb} +1 -4
- data/spec/dummy/app/models/posable_two.rb +5 -0
- data/spec/dummy/config/application.rb +59 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -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/20130308054001_create_posable_one.rb +8 -0
- data/spec/dummy/db/migrate/20130308054142_create_posable_two.rb +9 -0
- data/spec/dummy/db/schema.rb +41 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/assignments.rb +8 -0
- data/spec/factories/posable_one.rb +5 -0
- data/spec/factories/words.rb +7 -0
- data/spec/internal_helpers_spec.rb +40 -42
- data/spec/models/assignment_spec.rb +46 -0
- data/spec/models/word_spec.rb +42 -0
- data/spec/pose_api_spec.rb +198 -196
- data/spec/spec_helper.rb +21 -77
- data/spec/support/matchers.rb +0 -1
- metadata +83 -102
- data/doc/Pose/InstanceMethods.html +0 -341
- data/doc/Pose.html +0 -774
- data/doc/PoseAssignment.html +0 -125
- data/doc/PoseGenerator.html +0 -255
- data/doc/PoseMigrations.html +0 -261
- data/doc/PoseWord.html +0 -125
- data/doc/_index.html +0 -134
- data/doc/class_list.html +0 -47
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -55
- data/doc/css/style.css +0 -322
- data/doc/file_list.html +0 -46
- data/doc/frames.html +0 -13
- data/doc/index.html +0 -134
- data/doc/js/app.js +0 -205
- data/doc/js/full_list.js +0 -167
- data/doc/js/jquery.js +0 -16
- data/doc/method_list.html +0 -150
- data/doc/top-level-namespace.html +0 -172
- data/lib/generators/pose/install/install_generator.rb +0 -56
- data/lib/generators/pose/install/templates/install_migration.rb +0 -24
- data/lib/pose/models/pose_assignment.rb +0 -31
- data/lib/pose/models/pose_word.rb +0 -28
- data/spec/factories.rb +0 -15
- data/spec/pose_assignment_spec.rb +0 -45
- data/spec/pose_word_spec.rb +0 -26
data/README.md
CHANGED
@@ -70,6 +70,17 @@ To index all entries of `MyClass`, run `rake pose:reindex_all[MyClass]` on the c
|
|
70
70
|
At this point, you are all set up. Let's perform a search!
|
71
71
|
|
72
72
|
|
73
|
+
## Upgrading from version 1.x
|
74
|
+
|
75
|
+
Version 2 is a proper Rails engine, and comes with a slightly different database table schema.
|
76
|
+
Upgrading is as simple as
|
77
|
+
|
78
|
+
```bash
|
79
|
+
$ rails generate pose:upgrade
|
80
|
+
$ rake db:migrate
|
81
|
+
```
|
82
|
+
|
83
|
+
|
73
84
|
## Searching
|
74
85
|
|
75
86
|
To search, simply call Pose's `search` method, and tell it the search query as well as in which classes it should search.
|
data/Rakefile
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
require 'rake/dsl_definition'
|
3
2
|
begin
|
4
3
|
require 'bundler/setup'
|
5
4
|
rescue LoadError
|
6
5
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
6
|
end
|
8
|
-
|
7
|
+
|
8
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
9
|
+
load 'rails/tasks/engine.rake'
|
9
10
|
|
10
11
|
Bundler::GemHelper.install_tasks
|
11
12
|
|
12
13
|
# RSpec tasks.
|
14
|
+
require 'rspec/core/rake_task'
|
13
15
|
RSpec::Core::RakeTask.new :spec
|
14
16
|
task :default => :spec
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Assigns searchable objects to words in the search index.
|
2
|
+
module Pose
|
3
|
+
class Assignment < ActiveRecord::Base
|
4
|
+
attr_accessible :word, :posable
|
5
|
+
|
6
|
+
belongs_to :word, class_name: 'Pose::Word'
|
7
|
+
belongs_to :posable, polymorphic: true
|
8
|
+
|
9
|
+
# Removes all Assignments for the given class.
|
10
|
+
def self.delete_class_index clazz
|
11
|
+
Assignment.delete_all(posable_type: clazz.name)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Removes all Assignments that aren't used anymore.
|
15
|
+
def self.cleanup_orphaned_pose_assignments progress_bar = nil
|
16
|
+
Assignment.find_each(include: [:posable, :word], batch_size: 5000) do |assignment|
|
17
|
+
progress_bar.increment if progress_bar
|
18
|
+
|
19
|
+
# Delete the assignment if the posable object no longer exists.
|
20
|
+
if assignment.posable.nil?
|
21
|
+
puts "deleting assignment '#{assignment.id}' because the posable object no longer exists."
|
22
|
+
assignment.delete
|
23
|
+
next
|
24
|
+
end
|
25
|
+
|
26
|
+
# Delete the assignment if the Pose::Word for it no longer exists.
|
27
|
+
if assignment.word.nil?
|
28
|
+
puts "deleting assignment '#{assignment.id}' because its word no longer exists."
|
29
|
+
assignment.delete
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# A single word in the search index.
|
2
|
+
module Pose
|
3
|
+
class Word < ActiveRecord::Base
|
4
|
+
attr_accessible :text
|
5
|
+
|
6
|
+
has_many :assignments, class_name: 'Pose::Assignment', dependent: :destroy
|
7
|
+
|
8
|
+
def self.remove_unused_words progress_bar = nil
|
9
|
+
if Helpers.is_sql_database?
|
10
|
+
# SQL database --> use an optimized query.
|
11
|
+
Word.delete_all(id: Word.select("pose_words.id").
|
12
|
+
joins("LEFT OUTER JOIN pose_assignments ON pose_assignments.word_id = pose_words.id").
|
13
|
+
group("pose_words.id").
|
14
|
+
having("COUNT(pose_assignments.id) = 0"))
|
15
|
+
else
|
16
|
+
# Unknown database --> use the standard Rails API.
|
17
|
+
Word.select(:id).find_each(include: [:assignments], batch_size: 100) do |word|
|
18
|
+
word.delete if word.assignments.size == 0
|
19
|
+
progress_bar.increment if progress_bar
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class PoseInstall < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def change
|
4
|
+
create_table "pose_assignments" do |t|
|
5
|
+
t.integer "word_id", null: false
|
6
|
+
t.integer "posable_id", null: false
|
7
|
+
t.string "posable_type", limit: 60, null: false
|
8
|
+
end
|
9
|
+
add_index "pose_assignments", :word_id
|
10
|
+
add_index "pose_assignments", :posable_id
|
11
|
+
|
12
|
+
create_table "pose_words" do |t|
|
13
|
+
t.string "text", limit: 80, null: false
|
14
|
+
end
|
15
|
+
add_index "pose_words", :text
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -7,18 +7,16 @@ class AddPoseTables < ActiveRecord::Migration
|
|
7
7
|
|
8
8
|
def self.down
|
9
9
|
create_table "pose_assignments" do |t|
|
10
|
-
t.integer "
|
10
|
+
t.integer "word_id", null: false
|
11
11
|
t.integer "posable_id", null: false
|
12
|
-
t.string "posable_type", limit:
|
12
|
+
t.string "posable_type", limit: 60, null: false
|
13
13
|
end
|
14
|
-
|
15
|
-
add_index "pose_assignments", :pose_word_id
|
14
|
+
add_index "pose_assignments", :word_id
|
16
15
|
add_index "pose_assignments", :posable_id
|
17
16
|
|
18
17
|
create_table "pose_words" do |t|
|
19
18
|
t.string "text", limit: 80, null: false
|
20
19
|
end
|
21
|
-
|
22
20
|
add_index "pose_words", :text
|
23
21
|
end
|
24
22
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module Pose
|
5
|
+
module Generators
|
6
|
+
|
7
|
+
class UpgradeGenerator < Rails::Generators::Base
|
8
|
+
include Rails::Generators::Migration
|
9
|
+
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
10
|
+
|
11
|
+
def create_migration_file
|
12
|
+
say ''
|
13
|
+
say ' Creating database migration to upgrade your Pose tables.'
|
14
|
+
say ''
|
15
|
+
migration_template 'upgrade_migration.rb', 'db/migrate/pose_upgrade.rb'
|
16
|
+
say ''
|
17
|
+
end
|
18
|
+
|
19
|
+
def installation_instructions
|
20
|
+
say ' All done! You need to do is run db:migrate!'
|
21
|
+
say ''
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Helper method for creating the migration.
|
28
|
+
def self.next_migration_number(path)
|
29
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -2,9 +2,12 @@
|
|
2
2
|
module Pose
|
3
3
|
module ActiveRecordBaseAdditions
|
4
4
|
|
5
|
+
# Defines the searchable content in ActiveRecord objects.
|
5
6
|
def posify &block
|
6
|
-
raise "
|
7
|
-
|
7
|
+
raise "Error while posifying class '#{name}': " \
|
8
|
+
"You must provide a block that returns the searchable content to 'posify'." unless block_given?
|
9
|
+
|
10
|
+
include ModelClassAdditions
|
8
11
|
self.pose_content = block
|
9
12
|
end
|
10
13
|
|
data/lib/pose/engine.rb
ADDED
@@ -29,6 +29,12 @@ module Pose
|
|
29
29
|
end
|
30
30
|
|
31
31
|
|
32
|
+
def is_sql_database?
|
33
|
+
['ActiveRecord::ConnectionAdapters::PostgreSQLAdapter',
|
34
|
+
'ActiveRecord::ConnectionAdapters::SQLite3Adapter'].include? ActiveRecord::Base.connection.class.name
|
35
|
+
end
|
36
|
+
|
37
|
+
|
32
38
|
# Returns whether the given string is a URL.
|
33
39
|
#
|
34
40
|
# @param [String] word The string to check.
|
@@ -54,11 +60,11 @@ module Pose
|
|
54
60
|
# Returns a hash mapping classes to ids for the a single given word.
|
55
61
|
def search_classes_and_ids_for_word word, class_names
|
56
62
|
result = {}.tap { |hash| class_names.each { |class_name| hash[class_name] = [] }}
|
57
|
-
query =
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
63
|
+
query = Pose::Assignment.joins(:word) \
|
64
|
+
.select('pose_assignments.posable_id, pose_assignments.posable_type') \
|
65
|
+
.where('pose_words.text LIKE ?', "#{word}%") \
|
66
|
+
.where('posable_type IN (?)', class_names)
|
67
|
+
Pose::Assignment.connection.select_all(query.to_sql).each do |pose_assignment|
|
62
68
|
result[pose_assignment['posable_type']] << pose_assignment['posable_id'].to_i
|
63
69
|
end
|
64
70
|
result
|
@@ -73,7 +79,7 @@ module Pose
|
|
73
79
|
|
74
80
|
# Returns the search terms that are contained in the given query.
|
75
81
|
def query_terms query
|
76
|
-
query.split(' ').map{|query_word|
|
82
|
+
query.split(' ').map{|query_word| Helpers.root_word query_word}.flatten.uniq
|
77
83
|
end
|
78
84
|
|
79
85
|
# Simplifies the given word to a generic search form.
|
@@ -88,7 +94,7 @@ module Pose
|
|
88
94
|
raw_word_copy.gsub! /[()*<>'",;\?\-\=&%#]/, ' '
|
89
95
|
raw_word_copy.gsub! /\s+/, ' '
|
90
96
|
raw_word_copy.split(' ').each do |word|
|
91
|
-
if
|
97
|
+
if Helpers.is_url?(word)
|
92
98
|
result.concat word.split(/[\.\/\:]/).delete_if(&:blank?)
|
93
99
|
else
|
94
100
|
word.gsub! /[\-\/\._:]/, ' '
|
@@ -1,11 +1,11 @@
|
|
1
|
-
# Additions to posified ActiveRecord
|
1
|
+
# Additions to posified ActiveRecord classes.
|
2
2
|
module Pose
|
3
|
-
module
|
3
|
+
module ModelClassAdditions
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
has_many :pose_assignments, as: :posable, dependent: :delete_all
|
8
|
-
has_many :pose_words, through: :pose_assignments
|
7
|
+
has_many :pose_assignments, class_name: 'Pose::Assignment', as: :posable, dependent: :delete_all
|
8
|
+
has_many :pose_words, through: :pose_assignments, class_name: 'Pose::Word', source: :word
|
9
9
|
|
10
10
|
after_save :update_pose_index
|
11
11
|
before_destroy :delete_pose_index
|
@@ -29,15 +29,15 @@ module Pose
|
|
29
29
|
|
30
30
|
# Step 1: get an array of all words for the current object.
|
31
31
|
search_text = instance_eval &(self.class.pose_content)
|
32
|
-
new_words =
|
32
|
+
new_words = Helpers.query_terms search_text.to_s
|
33
33
|
|
34
34
|
# Step 2: Add new words to the search index.
|
35
|
-
|
36
|
-
self.pose_words <<
|
35
|
+
Helpers.get_words_to_add(self.pose_words, new_words).each do |word_to_add|
|
36
|
+
self.pose_words << Word.find_or_create_by_text(word_to_add)
|
37
37
|
end
|
38
38
|
|
39
39
|
# Step 3: Remove now obsolete words from search index.
|
40
|
-
|
40
|
+
Helpers.get_words_to_remove(self.pose_words, new_words).each do |word_to_remove|
|
41
41
|
self.pose_words.delete word_to_remove
|
42
42
|
end
|
43
43
|
end
|
data/lib/pose/railtie.rb
CHANGED
@@ -7,7 +7,7 @@ module Pose
|
|
7
7
|
# Add the Pose additions to ActiveRecord::Base once it is loaded.
|
8
8
|
initializer 'Pose.base_additions' do
|
9
9
|
ActiveSupport.on_load :active_record do
|
10
|
-
extend
|
10
|
+
extend ActiveRecordBaseAdditions
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -16,5 +16,4 @@ module Pose
|
|
16
16
|
load "tasks/pose_tasks.rake"
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
20
19
|
end
|
data/lib/pose/static_api.rb
CHANGED
@@ -17,7 +17,7 @@ module Pose
|
|
17
17
|
# @return [Array<String>]
|
18
18
|
def autocomplete_words query
|
19
19
|
return [] if query.blank?
|
20
|
-
|
20
|
+
Word.where('text LIKE ?', "#{Helpers.root_word(query)[0]}%").map(&:text)
|
21
21
|
end
|
22
22
|
|
23
23
|
|
@@ -41,11 +41,11 @@ module Pose
|
|
41
41
|
|
42
42
|
|
43
43
|
# Get the ids of the results.
|
44
|
-
class_names =
|
44
|
+
class_names = Helpers.make_array(classes).map &:name
|
45
45
|
result_classes_and_ids = {}
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
Helpers.query_terms(query).each do |query_word|
|
47
|
+
Helpers.search_classes_and_ids_for_word(query_word, class_names).each do |class_name, ids|
|
48
|
+
Helpers.merge_search_result_word_matches result_classes_and_ids, class_name, ids
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -92,6 +92,5 @@ module Pose
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
95
|
-
|
96
95
|
end
|
97
96
|
end
|
data/lib/pose/version.rb
CHANGED
data/lib/pose.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
|
2
|
-
require 'rake'
|
3
|
-
include Rake::DSL if defined? Rake::DSL
|
4
|
-
|
1
|
+
require "pose/engine"
|
5
2
|
require 'pose/static_api'
|
6
3
|
require 'pose/internal_helpers'
|
7
4
|
require 'pose/activerecord_base_additions'
|
8
|
-
require 'pose/
|
5
|
+
require 'pose/model_class_additions'
|
9
6
|
require 'pose/railtie' if defined? Rails
|
10
|
-
|
11
|
-
|
7
|
+
|
8
|
+
module Pose
|
9
|
+
end
|
data/lib/tasks/pose_tasks.rake
CHANGED
@@ -1,40 +1,38 @@
|
|
1
1
|
include Rake::DSL if defined?(Rake::DSL)
|
2
2
|
require 'ruby-progressbar'
|
3
|
-
namespace :pose do
|
4
3
|
|
5
|
-
|
4
|
+
namespace :pose do
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
desc "Cleans out unused data from the search index."
|
7
|
+
task :vacuum => :environment do |t, args|
|
8
|
+
puts "Cleaning Pose search index ...\n\n"
|
9
|
+
progress_bar = ProgressBar.create title: ' assignments', total: Pose::Assignment.count
|
10
|
+
Pose::Assignment.cleanup_orphaned_pose_assignments progress_bar
|
11
|
+
progress_bar.finish
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
progress_bar = ProgressBar.create title: ' words', total: Pose::Word.count
|
14
|
+
Pose::Word.remove_unused_words progress_bar
|
15
|
+
progress_bar.finish
|
17
16
|
|
18
|
-
|
19
|
-
|
17
|
+
puts "\nPose search index cleanup complete.\n\n"
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
desc "Removes the search index for all instances of the given classes."
|
21
|
+
task :remove, [:class_name] => :environment do |t, args|
|
22
|
+
clazz = args.class_name.constantize
|
23
|
+
Pose::Assignment.delete_class_index clazz
|
24
|
+
puts "Search index for class #{clazz.name} deleted.\n\n"
|
25
|
+
end
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
progress_bar.finish
|
27
|
+
desc "Deletes and recreates the search index for all instances of the given class."
|
28
|
+
task :reindex_all, [:class_name] => [:environment] do |t, args|
|
29
|
+
clazz = args.class_name.constantize
|
30
|
+
progress_bar = ProgressBar.create title: " reindexing", total: clazz.count
|
31
|
+
clazz.find_each do |instance|
|
32
|
+
instance.update_pose_words
|
33
|
+
progress_bar.increment
|
37
34
|
end
|
38
|
-
|
35
|
+
progress_bar.finish
|
39
36
|
end
|
37
|
+
|
40
38
|
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,59 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require
|
6
|
+
require "pose"
|
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 escaping HTML in JSON.
|
39
|
+
config.active_support.escape_html_entities_in_json = true
|
40
|
+
|
41
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
42
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
43
|
+
# like if you have constraints or database-specific column types
|
44
|
+
# config.active_record.schema_format = :sql
|
45
|
+
|
46
|
+
# Enforce whitelist mode for mass assignment.
|
47
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
48
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
49
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
50
|
+
config.active_record.whitelist_attributes = true
|
51
|
+
|
52
|
+
# Enable the asset pipeline
|
53
|
+
config.assets.enabled = true
|
54
|
+
|
55
|
+
# Version of your assets, change this if you want to expire all your assets
|
56
|
+
config.assets.version = '1.0'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
@@ -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
|
+
development:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: db/development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
13
|
+
# re-generated from your development database when you run "rake".
|
14
|
+
# Do not set this db to the same as development or production.
|
15
|
+
test:
|
16
|
+
adapter: sqlite3
|
17
|
+
database: db/test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
20
|
+
|
21
|
+
production:
|
22
|
+
adapter: sqlite3
|
23
|
+
database: db/production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|
@@ -0,0 +1,37 @@
|
|
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
|
+
# Raise exception on mass assignment protection for Active Record models
|
26
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
27
|
+
|
28
|
+
# Log the query plan for queries taking more than this (works
|
29
|
+
# with SQLite, MySQL, and PostgreSQL)
|
30
|
+
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
31
|
+
|
32
|
+
# Do not compress assets
|
33
|
+
config.assets.compress = false
|
34
|
+
|
35
|
+
# Expands the lines which load the assets
|
36
|
+
config.assets.debug = true
|
37
|
+
end
|