simple_form-dropdown_select 0.1.1 → 0.1.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: d9f1b3887b5061d8f2ee478623c3dec844c3c866
4
- data.tar.gz: ca82c4b4363dec54db9e269ab821b0f6aa1d308b
3
+ metadata.gz: 01d9cd42210ca45eba7c87399c6bd5a5d51a3e88
4
+ data.tar.gz: 3cd78dcac4b48b62e7b761898882f44f70929972
5
5
  SHA512:
6
- metadata.gz: c2afff27f072f8622026a1dcb2e630560e06ec81955258a681fbe59085e5109d359f3efe5bca3632a39d002caea5e85259e0887754fea93f5113707f5a0bbd8b
7
- data.tar.gz: d7e6720f01b7e48527ce2690db69d91f715f1effe268b3c041705d7d75991bf11ea453324d41976da2869c651ea843bb076c10220fc0de0b6f875c8c0f010582
6
+ metadata.gz: 217e0c8f276ae3583b8291dc1f746771ae38747813d7a352f524b5f0ab5d5c31cdd12bd5c43c1751dd3e9adb10360ce918642f871d1e3661e69dee03897c0abd
7
+ data.tar.gz: a033c6f30a12ce85b32731273ae8553acf41e43e85fab91ec284a7e458036b7c0cb57f1eaa2a2a90ae2e5b31f25015cae03c8c62aa300242a0351ba0067b2f46
@@ -3,8 +3,16 @@ class DropdownSelectInput < SimpleForm::Inputs::CollectionInput
3
3
  include ActionView::Helpers::TagHelper
4
4
  include ActionView::Context
5
5
 
6
+ def current_value
7
+ input_html_options[:value] || object.try(:send, attribute_name)
8
+ end
9
+
6
10
  def selected_option
7
- collection.find { |x| x[1] == object.send(attribute_name) }
11
+ if current_value
12
+ collection.find { |x| x[1] == current_value }
13
+ else
14
+ collection.first
15
+ end
8
16
  end
9
17
 
10
18
  def input(wrapper_options = nil)
@@ -1,5 +1,5 @@
1
1
  module SimpleForm
2
2
  module DropdownSelect
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form-dropdown_select
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Becker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-24 00:00:00.000000000 Z
11
+ date: 2014-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coffee-script