simple_form_extension 1.2.16 → 1.2.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,7 @@ module SimpleFormExtension
13
13
  # :'preload' => preload,
14
14
  #
15
15
  def input(wrapper_options = {})
16
- @attribute_name = reflection.foreign_key if relation?
16
+ @attribute_name = foreign_key if relation?
17
17
  input_html_options[:data] ||= {}
18
18
 
19
19
  input_html_options[:data].merge!(
@@ -87,7 +87,7 @@ module SimpleFormExtension
87
87
  [options, input_html_options].each do |hash|
88
88
  return hash[key] if hash.key?(key)
89
89
  end
90
-
90
+
91
91
  # Return default block value or nil if no block was given
92
92
  block ? block.call : nil
93
93
  end
@@ -107,6 +107,14 @@ module SimpleFormExtension
107
107
  def reflection
108
108
  @reflection ||= object.class.reflect_on_association(attribute_name)
109
109
  end
110
+
111
+ def foreign_key
112
+ @foreign_key ||= if reflection.class.in? [ActiveRecord::Reflection::ThroughReflection, ActiveRecord::Reflection::HasManyReflection]
113
+ reflection.foreign_key.pluralize
114
+ else
115
+ reflection.foreign_key
116
+ end
117
+ end
110
118
  end
111
119
  end
112
120
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleFormExtension
2
- VERSION = "1.2.16"
2
+ VERSION = "1.2.17"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form_extension
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.16
4
+ version: 1.2.17
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-24 00:00:00.000000000 Z
12
+ date: 2015-04-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails