rails-for_select 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rails/for_select.rb +8 -1
  3. metadata +18 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c43c1790cd61de3df6af23563baca36d668c0505
4
- data.tar.gz: fd2650c37a30e1a91d1e99e0d39cfc22a7b2dc40
3
+ metadata.gz: da05b0921161cbe8697c1ea2fa624da103f5094c
4
+ data.tar.gz: 2a6615a5cc94537ec3d2254e1177f352f3ca086e
5
5
  SHA512:
6
- metadata.gz: 1d5e54c83840819792fd82927a00dbaf7afbf0ebf9f573fe95ca8fdfb3c853e15612a5d32a132ad9300ccb187f844262695c603cb32fb226f7cf19cd574cc1e6
7
- data.tar.gz: 1830107e89be4b732ea4385c02c7f9bffe9e7f5f1bd24ad13e9a354c36e72959653dd5a990d8aa0c47cb9dfc33cf2c67991ba91649cee581e2d4549318b645d8
6
+ metadata.gz: 2b1ebf67cf734755fb6c7628375a1dc39b323f04932453c66b4a8e1e7918fc77f9c88c90ef1747e108eb09c871221a86584db50e00ba3d9564ec5d30c35d5be9
7
+ data.tar.gz: 43854cad89433cbfccb20bcb070060b7fcea476462a325dc1949e1c1a32edb83a37d5be750e7db5907d699bf898b7c38c74a68419fbbdf52c8c82483b8e09651
@@ -1,3 +1,5 @@
1
+ require 'active_record'
2
+
1
3
  module ForSelect
2
4
  module ClassMethods
3
5
  # Allow to call #for_select on each class inheriting from ActiveRecord::Base. Will generate a tuples array for use
@@ -16,7 +18,12 @@ module ForSelect
16
18
  # GameSystem.for_select(cache_key: :created_on) # => [["name", 1], ["other name", 2], ...]
17
19
  def for_select(id: :id, name: :name, cache_key: :updated_at)
18
20
  Rails.cache.fetch [self.to_s.tableize, :select, self.maximum(cache_key)] do
19
- pluck(name, id)
21
+ find_each.collect do |record|
22
+ [
23
+ record.send(name),
24
+ record.send(id),
25
+ ]
26
+ end
20
27
  end
21
28
  end
22
29
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-for_select
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emil Kampp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-30 00:00:00.000000000 Z
11
+ date: 2016-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.8
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.6.8
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rails
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -79,8 +93,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
93
  version: '0'
80
94
  requirements: []
81
95
  rubyforge_project:
82
- rubygems_version: 2.4.5.1
96
+ rubygems_version: 2.6.4
83
97
  signing_key:
84
98
  specification_version: 4
85
99
  summary: Exposes .for_select for use with Rails forms
86
100
  test_files: []
101
+ has_rdoc: