wonderful_simple_forms 0.1.4 → 0.1.5

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: d72cd88b9c8e6b7b62ef5234d982c49c64bec5ba
4
- data.tar.gz: 7cc21eac792ecbad164753fc2a5d1e4415bfe530
3
+ metadata.gz: ec8874850c970d67fb10a4b17e51cc58616cfde0
4
+ data.tar.gz: f1a39bce353becac8a35871516ce657b32981664
5
5
  SHA512:
6
- metadata.gz: 2b8967e2849732488936bb28bbf80bcd9ab22245229797cb37320d4e80de612b26e2b8490ca41465f63132cffc963d87edcf21246920b5019cd9e643fb45e463
7
- data.tar.gz: ee33de34c1c501610bca2a7a46f28635216413c4552591a08076b4bf38884f118a00f67c09abba86f534d81556a0ea19045e92cefb3470b96561e8a3975a33ff
6
+ metadata.gz: 55033114dc065971b6daa48ecefbfcb5401af52bd17c25cb6c9ef52c8366fe440f12f292c62b7f70a60ba538d123850e46803c35f9330c4c09006a98a73a4fe6
7
+ data.tar.gz: 14489bb7531945a11dbc02260ce171f1ba5d6edf207d1e95617c6af0e31120d5c2bf67ef14e60f6f29cbb0fda0307c0bc57544da2ba00957faec381b84197bd0
data/README.md CHANGED
@@ -1,8 +1,13 @@
1
1
  # WonderfulSimpleForms
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/wonderful_simple_forms`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Wonderful and simple forms!
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ Wonderful simple form aims to provide better enhancement for many types in simple_forms.
6
+
7
+ You only need to include this gem to get the benefits. Currently we add support to this formats:
8
+
9
+ - Enum
10
+ - Belongs_to
6
11
 
7
12
  ## Installation
8
13
 
@@ -22,17 +27,11 @@ Or install it yourself as:
22
27
 
23
28
  ## Usage
24
29
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+ Just include the gem! (and follow the simple_forms instalattion of course..)
32
31
 
33
32
  ## Contributing
34
33
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/wonderful_simple_forms. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
34
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hdf1986/wonderful_simple_forms. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
35
 
37
36
 
38
37
  ## License
@@ -13,7 +13,7 @@ module WonderfulSimpleForms
13
13
  end
14
14
 
15
15
  def default_input_type_with_belongs_to(*args, &block)
16
- att_name = (args.first || @attribute_name).to_s
16
+ att_name = (args.first || "#{@attribute_name}").to_s
17
17
  options = args.last
18
18
  return :belongs_to if (
19
19
  object.class.reflect_on_all_associations(:belongs_to).any? { |a| a.name == args.first })
@@ -34,17 +34,25 @@ module WonderfulSimpleForms
34
34
  end
35
35
 
36
36
  def enum_list
37
- object.class.method(attribute_name.to_s.pluralize.to_sym).call
37
+ object.class.method(attribute_name.to_s.pluralize.to_sym).call.keys
38
38
  end
39
39
  end
40
40
 
41
41
  class BelongsToInput < ::SimpleForm::Inputs::CollectionSelectInput
42
+ attr_reader :original_attribute_name
43
+
44
+ def initialize(builder, attribute_name, column, input_type, options = {})
45
+ @original_attribute_name = attribute_name
46
+ attribute_name = "#{attribute_name}_id".to_sym
47
+ super
48
+ end
49
+
42
50
  def collection
43
51
  @collection ||= enum_list
44
52
  end
45
53
 
46
54
  def enum_list
47
- attribute_name.to_s.classify.constantize.all.map{|instance|[instance.method(:name).call, instance.id]}
55
+ original_attribute_name.to_s.classify.constantize.all.map{|instance|[instance.method(:name).call, instance.id]}
48
56
  end
49
57
  end
50
58
  end
@@ -57,4 +65,4 @@ SimpleForm::FormBuilder.class_eval do
57
65
 
58
66
  alias_method_chain :default_input_type, :enum
59
67
  alias_method_chain :default_input_type, :belongs_to
60
- end
68
+ endr
@@ -1,3 +1,3 @@
1
1
  module WonderfulSimpleForms
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wonderful_simple_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - hdf1986
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-21 00:00:00.000000000 Z
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,6 +72,7 @@ files:
72
72
  - lib/wonderful_simple_forms.rb
73
73
  - lib/wonderful_simple_forms/simple_form.rb
74
74
  - lib/wonderful_simple_forms/version.rb
75
+ - wonderful_simple_forms-0.1.4.gem
75
76
  - wonderful_simple_forms.gemspec
76
77
  homepage: https://github.com/hdf1986/wonderful_simple_forms
77
78
  licenses: