active_admin_csv_import 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,26 @@
1
+ module Convenience
2
+ extend ActiveSupport::Concern
3
+
4
+ module ClassMethods
5
+ # Look up a belongs_to association by name.
6
+ # E.g.
7
+ # lookup_belongs_to :state, by: :name
8
+ # Adds state_name as an ivar.
9
+ def lookup_belongs_to(name, options)
10
+
11
+ lookup_by = options[:by]
12
+
13
+ code = <<-eoruby
14
+ attr_accessor :#{name}_#{lookup_by}
15
+
16
+ before_validation :lookup_#{name}_by_#{lookup_by}
17
+
18
+ def lookup_#{name}_by_#{lookup_by}
19
+ return if self.#{name}_#{lookup_by}.blank?
20
+ self.#{name} = '#{name}'.capitalize.constantize.where(#{lookup_by}: self.#{name}_#{lookup_by}).first
21
+ end
22
+ eoruby
23
+ class_eval(code)
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module ActiveAdminCsvImport
2
- VERSION = "1.1.2"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_csv_import
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-04 00:00:00.000000000 Z
12
+ date: 2014-01-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70178438708240 !ruby/object:Gem::Requirement
16
+ requirement: &70206387413640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70178438708240
24
+ version_requirements: *70206387413640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: railties
27
- requirement: &70178438707680 !ruby/object:Gem::Requirement
27
+ requirement: &70206387413060 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '3.1'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70178438707680
35
+ version_requirements: *70206387413060
36
36
  description: CSV import for Active Admin capable of handling CSV files too large to
37
37
  import via direct file upload to Heroku
38
38
  email:
@@ -42,6 +42,7 @@ extensions: []
42
42
  extra_rdoc_files: []
43
43
  files:
44
44
  - app/assets/javascripts/active_admin_csv_import/import_csv.js
45
+ - app/models/concerns/convenience.rb
45
46
  - app/views/admin/csv/_import_csv_failed_row.html.erb
46
47
  - app/views/admin/csv/_instructions.html.erb
47
48
  - app/views/admin/csv/import_csv.html.erb