listable_collections 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +101 -0
- data/Rakefile +37 -0
- data/lib/listable_collections/builder.rb +91 -0
- data/lib/listable_collections/extensions/active_record/base.rb +21 -0
- data/lib/listable_collections/railtie.rb +9 -0
- data/lib/listable_collections/version.rb +3 -0
- data/lib/listable_collections.rb +6 -0
- data/test/association_test.rb +25 -0
- data/test/attribute_test.rb +24 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/product.rb +15 -0
- data/test/dummy/app/models/shop.rb +13 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +27 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +10 -0
- data/test/dummy/config/database.yml.travis +19 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +56 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/migrate/20160916011427_create_shops.rb +9 -0
- data/test/dummy/db/migrate/20160916011451_create_products.rb +11 -0
- data/test/dummy/db/schema.rb +30 -0
- data/test/dummy/log/development.log +58 -0
- data/test/dummy/log/test.log +560 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/fixtures/products.yml +8 -0
- data/test/fixtures/shops.yml +3 -0
- data/test/test_helper.rb +21 -0
- metadata +194 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e8963f1810aa2b139c4c449502a8b0df20465c6b
|
4
|
+
data.tar.gz: 39ee8746a56e6f2ddb5957f89d9ed146290d9250
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 719b901eebf02b4bc8c8f68ab72fc865d06809ecb49a0d17653914ef6c67a0229ba0adbcc32c8cb0de7fd33676d1de8d16b7757b67ba9c17b9671b967296a17f
|
7
|
+
data.tar.gz: d89167bcd305e6c0196cca408454d621bf4bcf26bf211b3c6dddf98efb2baf6f369ef4a4a34ed27d68a55b5f8eeda7b097025db354b60315eb25570dc95a34b0
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 Mathías Montossi
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/listable_collections.svg)](http://badge.fury.io/rb/listable_collections)
|
2
|
+
[![Code Climate](https://codeclimate.com/github/mmontossi/listable_collections/badges/gpa.svg)](https://codeclimate.com/github/mmontossi/listable_collections)
|
3
|
+
[![Build Status](https://travis-ci.org/mmontossi/listable_collections.svg)](https://travis-ci.org/mmontossi/listable_collections)
|
4
|
+
[![Dependency Status](https://gemnasium.com/mmontossi/listable_collections.svg)](https://gemnasium.com/mmontossi/listable_collections)
|
5
|
+
|
6
|
+
# Listable collections
|
7
|
+
|
8
|
+
Makes collections accessible from a string list in rails.
|
9
|
+
|
10
|
+
## Install
|
11
|
+
|
12
|
+
Put this line in your Gemfile:
|
13
|
+
```ruby
|
14
|
+
gem 'listable_collections'
|
15
|
+
```
|
16
|
+
|
17
|
+
Then bundle:
|
18
|
+
```
|
19
|
+
$ bundle
|
20
|
+
```
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Use "list" method in your models to define what collections will be listed:
|
25
|
+
|
26
|
+
If you want to list an association:
|
27
|
+
```ruby
|
28
|
+
class Shop < ActiveRecord::Base
|
29
|
+
|
30
|
+
has_many :products
|
31
|
+
|
32
|
+
list :products, attribute: :name
|
33
|
+
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
Associated records won't be touched but changes will be tracked using "removed_from_list" and "added_to_list" helpers:
|
38
|
+
```ruby
|
39
|
+
shop.products.map(&:name) => ['iPhone']
|
40
|
+
shop.product_list => 'iPhone'
|
41
|
+
|
42
|
+
shop.product_list = 'iPod,iMac'
|
43
|
+
shop.products.map(&:name) => ['iPhone']
|
44
|
+
|
45
|
+
shop.added_products_to_list => ['iMac']
|
46
|
+
shop.removed_products_from_list => ['iPod']
|
47
|
+
```
|
48
|
+
|
49
|
+
If you want to list an array attribute:
|
50
|
+
```ruby
|
51
|
+
class Product < ActiveRecord::Base
|
52
|
+
|
53
|
+
serialize :sizes, Array
|
54
|
+
|
55
|
+
list :sizes
|
56
|
+
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
The attribute will be synced and chances will be tracked using "removed_from_list" and "added_to_list" helpers:
|
61
|
+
```ruby
|
62
|
+
product.sizes => ['64GB']
|
63
|
+
product.size_list => '64GB'
|
64
|
+
|
65
|
+
product.size_list = '32GB,128GB'
|
66
|
+
product.sizes => ['32GB','128GB']
|
67
|
+
|
68
|
+
product.added_sizes_to_list => ['128GB']
|
69
|
+
product.removed_sizes_from_list => ['64GB']
|
70
|
+
```
|
71
|
+
|
72
|
+
In some cases you may need to run some logic after changes, you can use "after_add" and "after_remove" callbacks for it:
|
73
|
+
```ruby
|
74
|
+
class Shop < ActiveRecord::Base
|
75
|
+
|
76
|
+
has_many :product
|
77
|
+
|
78
|
+
list :products, attribute: :name, after_add: :product_added, after_remove: :product_removed
|
79
|
+
|
80
|
+
def product_added(name)
|
81
|
+
# Some logic
|
82
|
+
end
|
83
|
+
|
84
|
+
def product_removed(name)
|
85
|
+
# Some logic
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
```
|
90
|
+
|
91
|
+
## Contributing
|
92
|
+
|
93
|
+
Because we've limited resources we'll mainly add features and keep a compatibility range close to what we need in our projects. However, contributions are more than welcome if someone wants to make any improvement.
|
94
|
+
|
95
|
+
## Credits
|
96
|
+
|
97
|
+
This gem is maintained and funded by [mmontossi](https://github.com/mmontossi).
|
98
|
+
|
99
|
+
## License
|
100
|
+
|
101
|
+
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'ListableCollections'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
|
25
|
+
load 'rails/tasks/engine.rake'
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module ListableCollections
|
2
|
+
class Builder
|
3
|
+
|
4
|
+
attr_reader :model
|
5
|
+
|
6
|
+
def initialize(model)
|
7
|
+
@model = model
|
8
|
+
end
|
9
|
+
|
10
|
+
def define(attribute, options)
|
11
|
+
plural = (options[:as] || attribute).to_s
|
12
|
+
singular = plural.singularize
|
13
|
+
name = "#{singular}_list"
|
14
|
+
variable = "@#{name}"
|
15
|
+
was = "#{name}_was"
|
16
|
+
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR < 2
|
17
|
+
model.skip_time_zone_conversion_for_attributes << name.to_sym
|
18
|
+
end
|
19
|
+
model.define_attribute_method name
|
20
|
+
define_list_writer name, variable, attribute, options
|
21
|
+
define_list_reader name, variable, attribute, options
|
22
|
+
define_added_to_list_reader plural, name, was
|
23
|
+
define_removed_from_list_reader plural, name, was
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def define_list_writer(name, variable, attribute, options)
|
29
|
+
model.class_eval do
|
30
|
+
define_method "#{name}=" do |value|
|
31
|
+
current_values = send(name).split(',')
|
32
|
+
new_values = value.split(',').reject(&:blank?).map(&:strip)
|
33
|
+
value = ((current_values & new_values) + (new_values - current_values))
|
34
|
+
if current_values.sort != new_values.sort
|
35
|
+
if options.has_key?(:attribute)
|
36
|
+
attribute_will_change! name
|
37
|
+
instance_variable_set variable, value.join(',')
|
38
|
+
else
|
39
|
+
attribute_will_change! name
|
40
|
+
send "#{attribute}=", value
|
41
|
+
end
|
42
|
+
if options.has_key?(:after_add)
|
43
|
+
(new_values - current_values).each do |added_value|
|
44
|
+
send options[:after_add], added_value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
if options.has_key?(:after_remove)
|
48
|
+
(current_values - new_values).each do |removed_value|
|
49
|
+
send options[:after_remove], removed_value
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def define_list_reader(name, variable, attribute, options)
|
58
|
+
model.class_eval do
|
59
|
+
define_method name do
|
60
|
+
if list = instance_variable_get(variable)
|
61
|
+
list
|
62
|
+
elsif values = send(attribute)
|
63
|
+
if options.has_key?(:attribute)
|
64
|
+
values = values.map do |record|
|
65
|
+
record.send options[:attribute]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
values.join(',')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def define_added_to_list_reader(plural, name, was)
|
75
|
+
model.class_eval do
|
76
|
+
define_method "added_#{plural}_to_list" do
|
77
|
+
send(name).split(',') - send(was).split(',')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def define_removed_from_list_reader(plural, name, was)
|
83
|
+
model.class_eval do
|
84
|
+
define_method "removed_#{plural}_from_list" do
|
85
|
+
send(was).split(',') - send(name).split(',')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ListableCollections
|
2
|
+
module Extensions
|
3
|
+
module ActiveRecord
|
4
|
+
module Base
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
|
9
|
+
def list(*args)
|
10
|
+
options = args.extract_options!
|
11
|
+
builder = Builder.new(self)
|
12
|
+
args.each do |attribute|
|
13
|
+
builder.define attribute, options
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class AssociationTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test 'accessor' do
|
6
|
+
apple = shops(:apple)
|
7
|
+
assert_equal 'iPhone,iPad', apple.product_list
|
8
|
+
|
9
|
+
imac = Product.new(name: 'iMac')
|
10
|
+
apple.expects(:product_added).never
|
11
|
+
apple.expects(:product_removed).never
|
12
|
+
apple.products << imac
|
13
|
+
assert_equal 'iPhone,iPad,iMac', apple.product_list
|
14
|
+
assert_equal [], apple.added_products_to_list
|
15
|
+
assert_equal [], apple.removed_products_from_list
|
16
|
+
|
17
|
+
apple.expects(:product_added).once.with('MacBook')
|
18
|
+
apple.expects(:product_removed).once.with('iPad')
|
19
|
+
apple.product_list = 'iMac,iPhone,MacBook'
|
20
|
+
assert_equal 'iPhone,iMac,MacBook', apple.product_list
|
21
|
+
assert_equal ['MacBook'], apple.added_products_to_list
|
22
|
+
assert_equal ['iPad'], apple.removed_products_from_list
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class AttributeTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test 'accessor' do
|
6
|
+
iphone = products(:iphone)
|
7
|
+
assert_equal '', iphone.size_list
|
8
|
+
|
9
|
+
iphone.expects(:size_added).never
|
10
|
+
iphone.expects(:size_removed).never
|
11
|
+
iphone.sizes << '64GB'
|
12
|
+
assert_equal '64GB', iphone.size_list
|
13
|
+
assert_equal [], iphone.added_sizes_to_list
|
14
|
+
assert_equal [], iphone.removed_sizes_from_list
|
15
|
+
|
16
|
+
iphone.expects(:size_added).once.with('32GB')
|
17
|
+
iphone.expects(:size_removed).once.with('64GB')
|
18
|
+
iphone.size_list = '32GB'
|
19
|
+
assert_equal '32GB', iphone.size_list
|
20
|
+
assert_equal ['32GB'], iphone.added_sizes_to_list
|
21
|
+
assert_equal ['64GB'], iphone.removed_sizes_from_list
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/test/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,27 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
require 'listable_collections'
|
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
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
+
|
18
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
+
# config.i18n.default_locale = :de
|
21
|
+
|
22
|
+
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
23
|
+
# Do not swallow errors in after_commit/after_rollback callbacks.
|
24
|
+
config.active_record.raise_in_transactional_callbacks = true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
mysql: &mysql
|
2
|
+
adapter: <%= 'jdbc' if RUBY_ENGINE == 'jruby' %>mysql<%= '2' if RUBY_ENGINE != 'jruby' %>
|
3
|
+
|
4
|
+
postgres: &postgres
|
5
|
+
adapter: <%= 'jdbc' if RUBY_ENGINE == 'jruby' %>postgresql
|
6
|
+
|
7
|
+
sqlite: &sqlite
|
8
|
+
adapter: <%= 'jdbc' if RUBY_ENGINE == 'jruby' %>sqlite3
|
9
|
+
|
10
|
+
default: &default
|
11
|
+
<<: *<%= ENV['DB'] %>
|
12
|
+
|
13
|
+
development:
|
14
|
+
<<: *default
|
15
|
+
database: travis
|
16
|
+
|
17
|
+
test:
|
18
|
+
<<: *default
|
19
|
+
database: travis
|
@@ -0,0 +1,41 @@
|
|
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
|
+
# 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
|