human_attribute_values 1.0.1 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +18 -0
- data/README.md +5 -5
- data/lib/human_attribute_values/human_attribute_value.rb +14 -12
- data/lib/human_attribute_values/version.rb +3 -1
- data/lib/human_attribute_values.rb +2 -0
- data/test/active_model_test.rb +62 -0
- data/test/{human_attribute_values_test.rb → active_record_test.rb} +14 -14
- data/test/dummy/Rakefile +3 -1
- data/test/dummy/app/controllers/application_controller.rb +2 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/active_model_child.rb +4 -0
- data/test/dummy/app/models/active_model_grand_child.rb +4 -0
- data/test/dummy/app/models/active_model_model.rb +7 -0
- data/test/dummy/app/models/active_model_parent.rb +7 -0
- data/test/dummy/app/models/active_model_sibling.rb +4 -0
- data/test/dummy/app/models/boolean_model.rb +2 -0
- data/test/dummy/app/models/child.rb +2 -0
- data/test/dummy/app/models/enum_model.rb +2 -0
- data/test/dummy/app/models/grand_child.rb +2 -0
- data/test/dummy/app/models/lexicon.rb +3 -1
- data/test/dummy/app/models/numeric_model.rb +2 -0
- data/test/dummy/app/models/parent.rb +2 -0
- data/test/dummy/app/models/sibling.rb +2 -0
- data/test/dummy/app/models/the_answer.rb +3 -0
- data/test/dummy/config/application.rb +5 -3
- data/test/dummy/config/boot.rb +4 -2
- data/test/dummy/config/environment.rb +3 -1
- data/test/dummy/config/environments/development.rb +2 -0
- data/test/dummy/config/environments/production.rb +2 -0
- data/test/dummy/config/environments/test.rb +4 -2
- data/test/dummy/config/initializers/backtrace_silencers.rb +2 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +2 -0
- data/test/dummy/config/initializers/inflections.rb +2 -0
- data/test/dummy/config/initializers/mime_types.rb +2 -0
- data/test/dummy/config/initializers/secret_token.rb +2 -0
- data/test/dummy/config/initializers/session_store.rb +2 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +2 -0
- data/test/dummy/config/locales/en.yml +32 -1
- data/test/dummy/config/routes.rb +2 -0
- data/test/dummy/config.ru +3 -1
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20150127220502_create_the_answers.rb +5 -1
- data/test/dummy/db/migrate/20150131153819_create_parents.rb +4 -1
- data/test/dummy/db/migrate/20150131161322_create_boolean_models.rb +4 -1
- data/test/dummy/db/migrate/20150131162551_create_numeric_models.rb +4 -1
- data/test/dummy/db/migrate/20150131164609_create_lexicons.rb +4 -3
- data/test/dummy/db/migrate/20150131170613_create_enum_models.rb +4 -1
- data/test/dummy/db/schema.rb +28 -30
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +364 -0
- data/test/dummy/log/test.log +4861 -200
- data/test/dummy/test/models/boolean_model_test.rb +2 -0
- data/test/dummy/test/models/child_test.rb +2 -0
- data/test/dummy/test/models/enum_model_test.rb +2 -0
- data/test/dummy/test/models/grand_child_test.rb +2 -0
- data/test/dummy/test/models/lexicon_test.rb +2 -0
- data/test/dummy/test/models/numeric_model_test.rb +2 -0
- data/test/dummy/test/models/sibling_test.rb +2 -0
- data/test/dummy/test/models/the_answer_test.rb +2 -0
- data/test/test_helper.rb +6 -4
- metadata +99 -67
- data/Rakefile +0 -32
- data/lib/tasks/human_attribute_value_tasks.rake +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e82c7256f6c4b632e16bae01cd454324a95573cdd7a95fc14bb3ad415e592094
|
4
|
+
data.tar.gz: 667e49801a7d7c3c096e3b6b51ccf47897d503c319c9297926c7e96fb39ee8df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8285916ea63486f87af3a94dba83eac908a98c29fcbfe3400810ba5dc1960ef4865f7ecb38299106865e13b422c905f2e908df21d39e1b4a51db4e19442d92a0
|
7
|
+
data.tar.gz: 83bccfa4da4094ce37bcad422390d53d9cab425f79c2f03a0aeaa252b7f139af9162f0c7cb27069acacd8a2a6af064ded063a22f91cc41015a7612b778ace56f
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
Please keep to the changelog format described on [keepachangelog.com](http://keepachangelog.com).
|
5
|
+
|
6
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- Added a changelog.
|
12
|
+
- Also include HumanAttributeValues into ActiveModel::Model.
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
- Instead of aborting and returning '' for associations of ActiveRecord::Base the lookup now proceeds with `assoc_attribute.to_s` as key (not meant to be done anyways).
|
16
|
+
|
17
|
+
### Removed
|
18
|
+
- Drop support for rails 4.1.8, including HumanAttributeValues into ActiveModel::Model does not add class method.
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
[![Build Status](https://travis-ci.org/RST-J/human_attribute_values.svg?branch=master)](https://travis-ci.org/RST-J/human_attribute_values)
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/human_attribute_values.svg)](http://badge.fury.io/rb/human_attribute_values)
|
4
4
|
|
5
|
-
human_attribute_values is a Rails plugin which provides translation for model attribute values using the Rails I18n API (analogously to [human_attribute_name](
|
5
|
+
human_attribute_values is a Rails plugin which provides translation for model attribute values using the Rails I18n API (analogously to [human_attribute_name](https://apidock.com/rails/v4.2.7/ActiveModel/Translation/human_attribute_name)).
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
```
|
@@ -10,12 +10,12 @@ gem install human_attribute_values
|
|
10
10
|
```
|
11
11
|
|
12
12
|
## Supported versions
|
13
|
-
* Rails: >= 4.
|
14
|
-
* Ruby: MRI >= 2.0
|
13
|
+
* Rails: >= 4.2.10
|
14
|
+
* Ruby: MRI >= 2.0
|
15
15
|
|
16
16
|
## Usage
|
17
|
-
The gem defines ``human_attribute_value``
|
18
|
-
To translate a value it uses the I18n API. The translations are looked up from the current locale file under the key ``'activerecord.values.model_name.attribute_name.value'`` by default.
|
17
|
+
The gem defines ``human_attribute_value`` as instance and class method on ``ActiveRecord::Base`` and ``ActiveModel::Model``.
|
18
|
+
To translate a value it uses the I18n API. The translations are looked up from the current locale file under the key ``'activerecord.values.model_name.attribute_name.value'`` respectively ``'activemodel.values.model_name.attribute_name.value'`` by default.
|
19
19
|
|
20
20
|
Locale:
|
21
21
|
```yml
|
@@ -1,25 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module HumanAttributeValues
|
2
4
|
extend ActiveSupport::Concern
|
3
5
|
|
4
|
-
included {}
|
5
|
-
|
6
6
|
def human_attribute_value(attribute, options = {})
|
7
|
-
value =
|
7
|
+
value = public_send(attribute)
|
8
8
|
self.class.human_attribute_value(attribute, value, options)
|
9
9
|
end
|
10
10
|
|
11
11
|
module ClassMethods
|
12
12
|
def human_attribute_value(attribute, value, options = {})
|
13
|
-
return '' if value.nil?
|
14
|
-
|
15
|
-
|
16
|
-
options = { count: 1 }.merge!(options)
|
17
|
-
parts = attribute.to_s.split(".")
|
13
|
+
return '' if value.nil? || value == ''
|
14
|
+
options = {count: 1}.merge!(options)
|
15
|
+
parts = attribute.to_s.split('.')
|
18
16
|
attribute = parts.pop
|
19
|
-
namespace = parts.join(
|
20
|
-
value_scope = "#{
|
17
|
+
namespace = parts.join('/') unless parts.empty?
|
18
|
+
value_scope = "#{i18n_scope}.values"
|
19
|
+
|
21
20
|
# dots would mean a new nesting level in YAML files
|
22
|
-
key = value.is_a?(Numeric) ? value.to_s.
|
21
|
+
key = value.is_a?(Numeric) ? value.to_s.tr('.', '_') : value
|
22
|
+
|
23
23
|
if namespace
|
24
24
|
defaults = lookup_ancestors.map do |klass|
|
25
25
|
:"#{value_scope}.#{klass.model_name.i18n_key}/#{namespace}.#{attribute}.#{key}"
|
@@ -30,14 +30,16 @@ module HumanAttributeValues
|
|
30
30
|
:"#{value_scope}.#{klass.model_name.i18n_key}.#{attribute}.#{key}"
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
33
34
|
defaults << :"values.#{attribute}.#{key}"
|
34
35
|
defaults << options.delete(:default) if options[:default]
|
35
36
|
defaults << value.to_s
|
37
|
+
|
36
38
|
options[:default] = defaults
|
37
39
|
I18n.translate(defaults.shift, options)
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
42
|
-
|
43
44
|
ActiveRecord::Base.send :include, HumanAttributeValues
|
45
|
+
ActiveModel::Model.send :include, HumanAttributeValues
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class ActiveModelTest < ActiveSupport::TestCase
|
6
|
+
test 'value with count config' do
|
7
|
+
instance = ActiveModelModel.new
|
8
|
+
instance.string_attr = 'goose'
|
9
|
+
assert_equal('one goose', instance.human_attribute_value(:string_attr), 'should use the mapping for count option 1 by default')
|
10
|
+
assert_equal('one goose', instance.human_attribute_value(:string_attr, count: 1), 'should use the mapping for count option 1 when explicitly specified')
|
11
|
+
assert_equal('some geese', instance.human_attribute_value(:string_attr, count: 2), 'should use the mapping for count other if count is not 1')
|
12
|
+
end
|
13
|
+
|
14
|
+
test 'value without count config' do
|
15
|
+
instance = ActiveModelModel.new
|
16
|
+
instance.integer_attr = 2
|
17
|
+
assert_equal('odd prime', instance.human_attribute_value(:integer_attr), 'should successfully translate without a count option')
|
18
|
+
assert_equal('odd prime', instance.human_attribute_value(:integer_attr, count: 1), 'should successfully translate with count option 1')
|
19
|
+
assert_equal('odd prime', instance.human_attribute_value(:integer_attr, count: 2), 'should successfully translate with count option 2')
|
20
|
+
end
|
21
|
+
|
22
|
+
test 'hierarchy resolution for STI models' do
|
23
|
+
grandchild = ActiveModelGrandChild.new
|
24
|
+
grandchild.inherited_attr = :one
|
25
|
+
assert_equal('active model grandchild value 1', grandchild.human_attribute_value(:inherited_attr), 'should use value for the actual class if present')
|
26
|
+
|
27
|
+
grandchild.inherited_attr = :two
|
28
|
+
assert_equal('active model child value 2', grandchild.human_attribute_value(:inherited_attr), 'should use value for the direct ancestor if it has a mapping')
|
29
|
+
|
30
|
+
grandchild.inherited_attr = :three
|
31
|
+
assert_equal('active model parent value 3', grandchild.human_attribute_value(:inherited_attr), 'should use value for the first parent class which has a mapping for the value')
|
32
|
+
|
33
|
+
grandchild.inherited_attr = :four
|
34
|
+
assert_equal('four', grandchild.human_attribute_value(:inherited_attr), 'should yield the value if there is no mapping in the type hierarchy')
|
35
|
+
end
|
36
|
+
|
37
|
+
test 'resolution of boolean values' do
|
38
|
+
instance = ActiveModelModel.new
|
39
|
+
instance.boolean_attr = false
|
40
|
+
assert_equal('This is false', instance.human_attribute_value(:boolean_attr), 'should translate boolean false')
|
41
|
+
|
42
|
+
instance.boolean_attr = true
|
43
|
+
assert_equal('true', instance.human_attribute_value(:boolean_attr), 'should return the stringified boolean if there is no mapping')
|
44
|
+
end
|
45
|
+
|
46
|
+
test 'resolution for numeric values' do
|
47
|
+
instance = ActiveModelModel.new
|
48
|
+
instance.decimal_attr = '2.71'.to_d
|
49
|
+
instance.float_attr = 3.14
|
50
|
+
instance.integer_attr = 9001
|
51
|
+
assert_equal('e', instance.human_attribute_value(:decimal_attr), 'should translate a decimal')
|
52
|
+
assert_equal('Pi', instance.human_attribute_value(:float_attr), 'should translate a float')
|
53
|
+
assert_equal('over 9000', instance.human_attribute_value(:integer_attr), 'should translate an integer')
|
54
|
+
|
55
|
+
instance.decimal_attr = '9.99'.to_d
|
56
|
+
instance.float_attr = 1.5
|
57
|
+
instance.integer_attr = 1001
|
58
|
+
assert_equal('9.99', instance.human_attribute_value(:decimal_attr), 'should return the stringified decimal if there is no mapping')
|
59
|
+
assert_equal('1.5', instance.human_attribute_value(:float_attr), 'should return the stringified float if there is no mapping')
|
60
|
+
assert_equal('1001', instance.human_attribute_value(:integer_attr), 'should return the stringified integer if there is no mapping')
|
61
|
+
end
|
62
|
+
end
|
@@ -1,25 +1,23 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
test "truth" do
|
5
|
-
assert_kind_of Module, HumanAttributeValues
|
6
|
-
end
|
3
|
+
require 'test_helper'
|
7
4
|
|
8
|
-
|
5
|
+
class ActiveRecordTest < ActiveSupport::TestCase
|
6
|
+
test 'attribute with count config' do
|
9
7
|
answer = TheAnswer.new(ultimate_truth: '42')
|
10
8
|
assert_equal('was calculated by Deep Thought', answer.human_attribute_value(:ultimate_truth), 'should use the mapping for count option 1 by default')
|
11
9
|
assert_equal('was calculated by Deep Thought', answer.human_attribute_value(:ultimate_truth, count: 1), 'should use the mapping for count option 1 when explicitly specified')
|
12
10
|
assert_equal('there is only one ultimate answer', answer.human_attribute_value(:ultimate_truth, count: 2), 'should use the mapping for count other if count is not 1')
|
13
11
|
end
|
14
12
|
|
15
|
-
test
|
13
|
+
test 'attribute without count config' do
|
16
14
|
answer = TheAnswer.new(ultimate_truth: 'wissen ist Nacht')
|
17
15
|
assert_equal('coined by Prof. Dr. Abdul Nachtigaller', answer.human_attribute_value(:ultimate_truth), 'should successfully translate without a count option')
|
18
16
|
assert_equal('coined by Prof. Dr. Abdul Nachtigaller', answer.human_attribute_value(:ultimate_truth, count: 1), 'should successfully translate with count option 1')
|
19
17
|
assert_equal('coined by Prof. Dr. Abdul Nachtigaller', answer.human_attribute_value(:ultimate_truth, count: 2), 'should successfully translate with count option 2')
|
20
18
|
end
|
21
19
|
|
22
|
-
test
|
20
|
+
test 'hierarchy resolution for STI models' do
|
23
21
|
grandchild = GrandChild.new(field: '1')
|
24
22
|
assert_equal('grandchild value 1', grandchild.human_attribute_value(:field), 'should use value for the actual class if present')
|
25
23
|
|
@@ -33,7 +31,7 @@ class HumanAttributeValuesTest < ActiveSupport::TestCase
|
|
33
31
|
assert_equal('4', grandchild.human_attribute_value(:field), 'should yield the value if there is no mapping in the type hierarchy')
|
34
32
|
end
|
35
33
|
|
36
|
-
test
|
34
|
+
test 'resolution of boolean values' do
|
37
35
|
boolean_model = BooleanModel.new(boolean_field: true)
|
38
36
|
assert_equal('This is true', boolean_model.human_attribute_value(:boolean_field), 'should translate boolean true')
|
39
37
|
|
@@ -41,7 +39,7 @@ class HumanAttributeValuesTest < ActiveSupport::TestCase
|
|
41
39
|
assert_equal('false', boolean_model.human_attribute_value(:boolean_field), 'should return the stringified boolean if there is no mapping')
|
42
40
|
end
|
43
41
|
|
44
|
-
test
|
42
|
+
test 'resolution for numeric values' do
|
45
43
|
numeric_model = NumericModel.new(integer_field: 1, decimal_field: 1.0)
|
46
44
|
assert_equal('One', numeric_model.human_attribute_value(:integer_field), 'should translate an integer')
|
47
45
|
assert_equal('One point zero', numeric_model.human_attribute_value(:decimal_field), 'should translate a decimal')
|
@@ -52,12 +50,14 @@ class HumanAttributeValuesTest < ActiveSupport::TestCase
|
|
52
50
|
assert_equal('2.0', numeric_model.human_attribute_value(:decimal_field), 'should return the stringified decimal if there is no mapping')
|
53
51
|
end
|
54
52
|
|
55
|
-
test
|
56
|
-
lexicon = Lexicon.new
|
57
|
-
|
53
|
+
test 'resolution for associations' do
|
54
|
+
lexicon = Lexicon.new
|
55
|
+
the_answer = TheAnswer.new(lexicon: lexicon)
|
56
|
+
assert_equal(lexicon.to_s, the_answer.human_attribute_value(:lexicon), 'should return .to_s for associations 1')
|
57
|
+
assert_equal(lexicon.the_answers.to_s, lexicon.human_attribute_value(:the_answers), 'should return .to_s for associations 2')
|
58
58
|
end
|
59
59
|
|
60
|
-
test
|
60
|
+
test 'resolution for enums' do
|
61
61
|
enum_model = EnumModel.new(status: :dead_and_alive)
|
62
62
|
assert_equal('The box has not been opened yet', enum_model.human_attribute_value(:status), 'should use the enumerated values for lookup')
|
63
63
|
|
data/test/dummy/Rakefile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
4
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
5
|
|
4
|
-
require File.expand_path('
|
6
|
+
require File.expand_path('config/application', __dir__)
|
5
7
|
|
6
8
|
Dummy::Application.load_tasks
|
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('boot', __dir__)
|
2
4
|
|
3
5
|
require 'rails/all'
|
4
6
|
|
5
7
|
Bundler.require(*Rails.groups)
|
6
|
-
require
|
8
|
+
require 'human_attribute_values'
|
7
9
|
|
8
10
|
module Dummy
|
9
11
|
class Application < Rails::Application
|
@@ -18,6 +20,6 @@ module Dummy
|
|
18
20
|
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
21
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
22
|
# config.i18n.default_locale = :de
|
23
|
+
config.active_record.sqlite3.represent_boolean_as_integer = true if config.active_record.sqlite3.respond_to?(:represent_boolean_as_integer)
|
21
24
|
end
|
22
25
|
end
|
23
|
-
|
data/test/dummy/config/boot.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Set up gems listed in the Gemfile.
|
2
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('
|
4
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
|
3
5
|
|
4
6
|
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
5
|
-
$LOAD_PATH.unshift File.expand_path('
|
7
|
+
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Dummy::Application.configure do
|
2
4
|
# Settings specified here will take precedence over those in config/application.rb.
|
3
5
|
|
@@ -13,8 +15,8 @@ Dummy::Application.configure do
|
|
13
15
|
config.eager_load = false
|
14
16
|
|
15
17
|
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
-
config.serve_static_files
|
17
|
-
config.static_cache_control =
|
18
|
+
config.serve_static_files = true
|
19
|
+
config.static_cache_control = 'public, max-age=3600'
|
18
20
|
|
19
21
|
# Show full error reports and disable caching.
|
20
22
|
config.consider_all_requests_local = true
|
@@ -1,5 +1,36 @@
|
|
1
1
|
en:
|
2
|
-
|
2
|
+
activemodel:
|
3
|
+
values:
|
4
|
+
active_model_model:
|
5
|
+
boolean_attr:
|
6
|
+
'false': 'This is false'
|
7
|
+
decimal_attr:
|
8
|
+
'2_71': e
|
9
|
+
float_attr:
|
10
|
+
'3_14': Pi
|
11
|
+
integer_attr:
|
12
|
+
'2': odd prime
|
13
|
+
'9001': 'over 9000'
|
14
|
+
string_attr:
|
15
|
+
'goose':
|
16
|
+
one: one goose
|
17
|
+
other: some geese
|
18
|
+
active_model_parent:
|
19
|
+
inherited_attr:
|
20
|
+
one: 'active model parent value 1'
|
21
|
+
two: 'active model parent value 2'
|
22
|
+
three: 'active model parent value 3'
|
23
|
+
active_model_child:
|
24
|
+
inherited_attr:
|
25
|
+
one: 'active model child value 1'
|
26
|
+
two: 'active model child value 2'
|
27
|
+
active_model_sibling:
|
28
|
+
inherited_attr:
|
29
|
+
four: 'active model sibling value 4'
|
30
|
+
active_model_grand_child:
|
31
|
+
inherited_attr:
|
32
|
+
one: 'active model grandchild value 1'
|
33
|
+
activerecord:
|
3
34
|
models:
|
4
35
|
the_answer: The ultimate Answer
|
5
36
|
attributes:
|
data/test/dummy/config/routes.rb
CHANGED
data/test/dummy/config.ru
CHANGED
Binary file
|
@@ -1,7 +1,11 @@
|
|
1
|
-
|
1
|
+
superclass = ActiveRecord::Migration
|
2
|
+
superclass = ActiveRecord::Migration[5.1] if superclass.respond_to?(:[])
|
3
|
+
|
4
|
+
class CreateTheAnswers < superclass
|
2
5
|
def change
|
3
6
|
create_table :the_answers do |t|
|
4
7
|
t.string :ultimate_truth
|
8
|
+
t.references :lexicon, index: true
|
5
9
|
|
6
10
|
t.timestamps
|
7
11
|
end
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
superclass = ActiveRecord::Migration
|
2
|
+
superclass = ActiveRecord::Migration[5.1] if superclass.respond_to?(:[])
|
3
|
+
|
4
|
+
class CreateBooleanModels < superclass
|
2
5
|
def change
|
3
6
|
create_table :boolean_models do |t|
|
4
7
|
t.boolean :boolean_field
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
superclass = ActiveRecord::Migration
|
2
|
+
superclass = ActiveRecord::Migration[5.1] if superclass.respond_to?(:[])
|
3
|
+
|
4
|
+
class CreateNumericModels < superclass
|
2
5
|
def change
|
3
6
|
create_table :numeric_models do |t|
|
4
7
|
t.integer :integer_field
|
@@ -1,8 +1,9 @@
|
|
1
|
-
|
1
|
+
superclass = ActiveRecord::Migration
|
2
|
+
superclass = ActiveRecord::Migration[5.1] if superclass.respond_to?(:[])
|
3
|
+
|
4
|
+
class CreateLexicons < superclass
|
2
5
|
def change
|
3
6
|
create_table :lexicons do |t|
|
4
|
-
t.references :the_answer, index: true
|
5
|
-
|
6
7
|
t.timestamps
|
7
8
|
end
|
8
9
|
end
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
superclass = ActiveRecord::Migration
|
2
|
+
superclass = ActiveRecord::Migration[5.1] if superclass.respond_to?(:[])
|
3
|
+
|
4
|
+
class CreateEnumModels < superclass
|
2
5
|
def change
|
3
6
|
create_table :enum_models do |t|
|
4
7
|
t.integer :status
|