collection2csv 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1434f97f5450add093a1e2411991a8f679a00172
4
- data.tar.gz: 8c4ed5cb81a6e2e1b390902ed67be697be2e3142
3
+ metadata.gz: 43ae44a7c263e2b23ab48ec1fe14f2953be6b780
4
+ data.tar.gz: 7def884e570400c259567f02d658dbf737277157
5
5
  SHA512:
6
- metadata.gz: 02e5415857977ed3c900c3e07daf3dcf25ca3610d53f6f6c6a7bdcbcd1785f8cef78e1dfc5c8f907daff3a6b370b051a4fe720fe07551fc1161def8d5f256369
7
- data.tar.gz: 6b40e544925592af75a36b5012ee3df065b8786c577f945a8b19bb5d63901b1b7b5a3997e39271ee25f70a6c4be8d645e1902441132de98e58ce1b072a2e9f85
6
+ metadata.gz: 1882a29a6ff91646cda97de146fd0843f069f6ebf510dbe55813563c76e079cf93f938e38d755fceada81faaf1c7c765354ec7c3533aba33afa3d7d20af5c8b3
7
+ data.tar.gz: 69649b2bdd4534f9343791007be068b48b55b2908a2077cab4b5c70d529682125c7b7855ef9d328e1e7fe674513110af4351cfccb00f50828761c54b2bc4ed51
@@ -14,6 +14,8 @@ class Collection2csvController < ApplicationController
14
14
  end
15
15
  end
16
16
 
17
+ private
18
+
17
19
  def to_csv(collection,column_names)
18
20
  CSV.generate do |csv|
19
21
  csv << column_names.map(&:humanize)
@@ -1,7 +1,8 @@
1
1
  module CollectionToCsvHelper
2
- def collection_download(collection,column_names={})
2
+ def collection_download(collection,column_names={})
3
+ klass = collection.try(:first).class
4
+ raise "#{collection} is not a ActiveRecord collection" unless klass.ancestors.include?(ActiveRecord::Base)
3
5
  collection_ids = collection.map(&:id)
4
- klass = collection.first.class
5
- link_to "Download" , collection2csv_path(ids: collection_ids,klass: klass,format: "csv",column_names: column_names)
6
- end
6
+ link_to "Download" , collection2csv_path(ids: collection_ids,klass: klass,format: "csv",column_names: column_names)
7
+ end
7
8
  end
@@ -1,3 +1,3 @@
1
1
  module Collection2csv
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collection2csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ethiraj
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-23 00:00:00.000000000 Z
11
+ date: 2016-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler