enum_help 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 +4 -4
- data/README.md +5 -3
- data/lib/enum_help/simple_form.rb +2 -2
- data/lib/enum_help/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c504a099701017b88b9e5f3f781aa88717c1bbc0
|
4
|
+
data.tar.gz: bf5811bb829fad9955d54c10ef5a8405ca7fa74c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0ff615ddf351263c16038482af1aada36b9d965cab244f2108b84eeb169f4184fd76e41953b842896b8265e90f05580d8fa5efdeda90fa45aac4e5a15e150b6
|
7
|
+
data.tar.gz: dcd97106d95b18dcceeb8461ebe572eb59fe4f0a088bd4877ec8a05f4eb1072d3cec66dc209bb523f9ae8c2a665a7b4a12e2b65e462ad548b9ba8b1e3f934a6c
|
data/README.md
CHANGED
@@ -28,6 +28,8 @@ Or install it yourself as:
|
|
28
28
|
## Usage
|
29
29
|
|
30
30
|
|
31
|
+
required Rails 4.1.x
|
32
|
+
|
31
33
|
In model file:
|
32
34
|
|
33
35
|
class Order < ActiveRecord::Base
|
@@ -37,7 +39,7 @@ In model file:
|
|
37
39
|
You can call:
|
38
40
|
|
39
41
|
order = Order.first
|
40
|
-
order.
|
42
|
+
order.update_attribute :status, 0
|
41
43
|
order.status
|
42
44
|
# > nopayment
|
43
45
|
order.status_i18n
|
@@ -47,9 +49,9 @@ In _form.html.erb using simple form:
|
|
47
49
|
|
48
50
|
<%= f.input :status %>
|
49
51
|
|
50
|
-
will generate select field with translations.
|
52
|
+
This will generate select field with translations automaticlly.
|
51
53
|
|
52
|
-
|
54
|
+
Other arguments for simple_form are supported perfectly.
|
53
55
|
|
54
56
|
e.g.
|
55
57
|
|
@@ -17,8 +17,8 @@ module EnumHelp
|
|
17
17
|
def initialize(*args)
|
18
18
|
super
|
19
19
|
raise "Attribute '#{attribute_name}' has no enum class" unless enum = object.class.send(attribute_name.to_s.pluralize)
|
20
|
-
collect = enum.
|
21
|
-
collect.unshift args.last[:prompt] if args.last.is_a?(Hash) && args.last[:prompt]
|
20
|
+
collect = enum.collect{|k,v| [::I18n.t("enums.#{object.class.to_s.downcase}.#{attribute_name}.#{k}", default: k),k] }
|
21
|
+
collect.unshift [args.last[:prompt],''] if args.last.is_a?(Hash) && args.last[:prompt]
|
22
22
|
|
23
23
|
if respond_to?(:input_options)
|
24
24
|
input_options[:collection] = collect
|
data/lib/enum_help/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enum_help
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lester Zhao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|