enum_help 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6156968aa38d6bac599e284db6dbac69d16ae9a6
4
- data.tar.gz: 49ba73d267e27a34ca82b2c9aab65b5da0306fa4
3
+ metadata.gz: c504a099701017b88b9e5f3f781aa88717c1bbc0
4
+ data.tar.gz: bf5811bb829fad9955d54c10ef5a8405ca7fa74c
5
5
  SHA512:
6
- metadata.gz: a17ede36b487c13c0fd18b1594908984e9585f978ab2d7f00cbaa231e0cba8f835f301b32b50c2b859e30cd5f404f5a9267e222086816a7d6b8ba60a5f72e386
7
- data.tar.gz: 162e3c1db97fb62499f23f6cf70d1a240cceba0d3a7f406b8fc864835230e3cf91cf963a15c2c5399f3e9edbfdd573015fbc2eecad70c0fe7bab9a39d469812e
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.update_attribut :status, 0
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
- other arguments for simple_form are supported perfectly.
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.keys
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
@@ -1,3 +1,3 @@
1
1
  module EnumHelp
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-05 00:00:00.000000000 Z
11
+ date: 2014-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler