activemodel 3.0.6.rc1 → 3.0.6.rc2
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/lib/active_model/errors.rb
CHANGED
@@ -295,8 +295,8 @@ module ActiveModel
|
|
295
295
|
end
|
296
296
|
|
297
297
|
defaults = @base.class.lookup_ancestors.map do |klass|
|
298
|
-
[ :"#{@base.class.i18n_scope}.errors.models.#{klass.model_name.
|
299
|
-
:"#{@base.class.i18n_scope}.errors.models.#{klass.model_name.
|
298
|
+
[ :"#{@base.class.i18n_scope}.errors.models.#{klass.model_name.i18n_key}.attributes.#{attribute}.#{type}",
|
299
|
+
:"#{@base.class.i18n_scope}.errors.models.#{klass.model_name.i18n_key}.#{type}" ]
|
300
300
|
end
|
301
301
|
|
302
302
|
defaults << options.delete(:message)
|
data/lib/active_model/naming.rb
CHANGED
@@ -2,7 +2,7 @@ require 'active_support/inflector'
|
|
2
2
|
|
3
3
|
module ActiveModel
|
4
4
|
class Name < String
|
5
|
-
attr_reader :singular, :plural, :element, :collection, :partial_path
|
5
|
+
attr_reader :singular, :plural, :element, :collection, :partial_path, :i18n_key
|
6
6
|
alias_method :cache_key, :collection
|
7
7
|
|
8
8
|
def initialize(klass)
|
@@ -14,6 +14,7 @@ module ActiveModel
|
|
14
14
|
@human = ActiveSupport::Inflector.humanize(@element).freeze
|
15
15
|
@collection = ActiveSupport::Inflector.tableize(self).freeze
|
16
16
|
@partial_path = "#{@collection}/#{@element}".freeze
|
17
|
+
@i18n_key = ActiveSupport::Inflector.underscore(self).tr('/', '.').to_sym
|
17
18
|
end
|
18
19
|
|
19
20
|
# Transform the model name into a more humane format, using I18n. By default,
|
@@ -27,8 +28,9 @@ module ActiveModel
|
|
27
28
|
@klass.respond_to?(:i18n_scope)
|
28
29
|
|
29
30
|
defaults = @klass.lookup_ancestors.map do |klass|
|
30
|
-
klass.model_name.
|
31
|
-
|
31
|
+
[klass.model_name.i18n_key,
|
32
|
+
klass.model_name.i18n_key.to_s.tr('.', '/').to_sym]
|
33
|
+
end.flatten
|
32
34
|
|
33
35
|
defaults << options.delete(:default) if options[:default]
|
34
36
|
defaults << @human
|
@@ -51,6 +53,9 @@ module ActiveModel
|
|
51
53
|
# BookCover.model_name # => "BookCover"
|
52
54
|
# BookCover.model_name.human # => "Book cover"
|
53
55
|
#
|
56
|
+
# BookCover.model_name.i18n_key # => "book_cover"
|
57
|
+
# BookModule::BookCover.model_name.i18n_key # => "book_module.book_cover"
|
58
|
+
#
|
54
59
|
# Providing the functionality that ActiveModel::Naming provides in your object
|
55
60
|
# is required to pass the Active Model Lint test. So either extending the provided
|
56
61
|
# method below, or rolling your own is required..
|
@@ -44,8 +44,9 @@ module ActiveModel
|
|
44
44
|
# Specify +options+ with additional translating options.
|
45
45
|
def human_attribute_name(attribute, options = {})
|
46
46
|
defaults = lookup_ancestors.map do |klass|
|
47
|
-
:"#{self.i18n_scope}.attributes.#{klass.model_name.
|
48
|
-
|
47
|
+
[:"#{self.i18n_scope}.attributes.#{klass.model_name.i18n_key}.#{attribute}",
|
48
|
+
:"#{self.i18n_scope}.attributes.#{klass.model_name.i18n_key.to_s.tr('.', '/')}.#{attribute}"]
|
49
|
+
end.flatten
|
49
50
|
|
50
51
|
defaults << :"attributes.#{attribute}"
|
51
52
|
defaults << options.delete(:default) if options[:default]
|
data/lib/active_model/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15424065
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
9
|
- 6
|
10
10
|
- rc
|
11
|
-
-
|
12
|
-
version: 3.0.6.
|
11
|
+
- 2
|
12
|
+
version: 3.0.6.rc2
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- David Heinemeier Hansson
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-03-
|
20
|
+
date: 2011-03-30 00:00:00 -07:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
requirements:
|
29
29
|
- - "="
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
hash:
|
31
|
+
hash: 15424065
|
32
32
|
segments:
|
33
33
|
- 3
|
34
34
|
- 0
|
35
35
|
- 6
|
36
36
|
- rc
|
37
|
-
-
|
38
|
-
version: 3.0.6.
|
37
|
+
- 2
|
38
|
+
version: 3.0.6.rc2
|
39
39
|
type: :runtime
|
40
40
|
version_requirements: *id001
|
41
41
|
- !ruby/object:Gem::Dependency
|