awesome_form_attributes 0.0.1 → 0.0.2
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 +7 -7
- data/awesome_form_attributes.gemspec +1 -1
- data/lib/awesome_form_attributes.rb +2 -0
- data/lib/awesome_form_attributes/helpers.rb +6 -2
- data/lib/awesome_form_attributes/setting.rb +16 -0
- data/lib/awesome_form_attributes/used_attr_columns.rb +4 -3
- data/lib/awesome_form_attributes/version.rb +1 -1
- metadata +31 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
|
4
|
-
|
5
|
-
SHA512:
|
6
|
-
|
7
|
-
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 77ea3b90f59a11a3da94953d14ec25b36cca3e0f
|
4
|
+
data.tar.gz: 989217e41491388734106ebe40d0b74066e9f046
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 20a544c2a6633f6cd81945b9c4f2a9ea4027e4874b019a05a55c92aa7042d403513e0a350f3a3fcf6e35107eca17431a336208f51d739ace32bd7ea93c3fe7c6
|
7
|
+
data.tar.gz: bac97afd0faf1f2cdeb57949199b4ea93da40119d1053ddf97094f8ee98be66e582a59f6d33387b789838950e2323096b9ceb283de96b83240aec8ecf0061ce9
|
@@ -4,8 +4,12 @@ module ActionView
|
|
4
4
|
[["是", 1], ["否", 0]]
|
5
5
|
end
|
6
6
|
|
7
|
-
def localize_attr(sym,
|
8
|
-
|
7
|
+
def localize_attr(sym, opts = {})
|
8
|
+
klass = controller_name.classify.constantize
|
9
|
+
displayed_name = I18n.t("#{klass.displayed_columns_local_path}.#{sym.to_s}")
|
10
|
+
basic_name = I18n.t("#{klass.default_local_path}.#{sym.to_s}")
|
11
|
+
return displayed_name || basic_name if opts[:display] == true
|
12
|
+
basic_name
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
@@ -3,4 +3,20 @@ class << ActiveRecord::Base
|
|
3
3
|
end
|
4
4
|
end
|
5
5
|
|
6
|
+
class ActiveRecord::Base
|
7
|
+
class << self
|
8
|
+
def oname
|
9
|
+
self.table_name.singularize
|
10
|
+
end
|
11
|
+
|
12
|
+
def default_local_path(singname = oname)
|
13
|
+
"activerecord.attributes.#{singname}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def displayed_columns_local_path(singname = oname)
|
17
|
+
"awesome_form_attributes.displayed_columns.#{singname}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
6
22
|
|
@@ -3,13 +3,14 @@ module UsedAttrColumns
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
module ClassMethods
|
6
|
-
end
|
7
6
|
|
7
|
+
end
|
8
|
+
|
8
9
|
def used_attrs
|
9
|
-
I18n.t(
|
10
|
+
I18n.t(self.class.default_local_path).try(:keys) || []
|
10
11
|
end
|
11
12
|
|
12
13
|
def short_used_attrs
|
13
|
-
[]
|
14
|
+
base_clos = I18n.t(self.class.displayed_columns_local_path).try(:keys) || used_attrs[0, 5]
|
14
15
|
end
|
15
16
|
end
|
metadata
CHANGED
@@ -1,37 +1,36 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: awesome_form_attributes
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Zhimeng Sun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-11-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: "0"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
23
20
|
type: :runtime
|
24
|
-
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
description: Easy way to write attributes for DB based Object in the VIEWS
|
26
|
-
email:
|
28
|
+
email:
|
27
29
|
- zhimengSun@gmail.com
|
28
30
|
executables: []
|
29
|
-
|
30
31
|
extensions: []
|
31
|
-
|
32
32
|
extra_rdoc_files: []
|
33
|
-
|
34
|
-
files:
|
33
|
+
files:
|
35
34
|
- .gitignore
|
36
35
|
- README.md
|
37
36
|
- awesome_form_attributes.gemspec
|
@@ -42,26 +41,25 @@ files:
|
|
42
41
|
- lib/awesome_form_attributes/version.rb
|
43
42
|
homepage: https://github.com/zhimengSun/awesome_form_attributes
|
44
43
|
licenses: []
|
45
|
-
|
46
44
|
metadata: {}
|
47
|
-
|
48
45
|
post_install_message:
|
49
46
|
rdoc_options: []
|
50
|
-
|
51
|
-
require_paths:
|
47
|
+
require_paths:
|
52
48
|
- lib
|
53
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
-
requirements:
|
55
|
-
-
|
56
|
-
|
57
|
-
|
58
|
-
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
59
|
requirements: []
|
60
|
-
|
61
60
|
rubyforge_project:
|
62
61
|
rubygems_version: 2.4.2
|
63
62
|
signing_key:
|
64
63
|
specification_version: 4
|
65
64
|
summary: Easy way to write attributes for DB based Object
|
66
65
|
test_files: []
|
67
|
-
|