rails_admin_import 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -7
- data/app/views/rails_admin/main/import.html.erb +2 -2
- data/lib/rails_admin_import/import.rb +6 -2
- metadata +2 -2
data/README.md
CHANGED
@@ -10,15 +10,15 @@ Installation
|
|
10
10
|
|
11
11
|
gem "rails_admin_import", :git => "git://github.com/stephskardal/rails_admin_import.git"
|
12
12
|
|
13
|
-
* Next, mount in your application by adding:
|
13
|
+
* Next, mount in your application by adding following line to your config/routes.rb:
|
14
14
|
|
15
|
-
mount RailsAdminImport::Engine => '/rails_admin_import', :as => 'rails_admin_import'
|
15
|
+
mount RailsAdminImport::Engine => '/rails_admin_import', :as => 'rails_admin_import'
|
16
16
|
|
17
|
-
* Add to cancan to allow access to import:
|
17
|
+
* Add to cancan to allow access to import in your app/models/ability.rb:
|
18
18
|
|
19
19
|
can :import, [User, Model1, Model2]
|
20
20
|
|
21
|
-
* Define configuration:
|
21
|
+
* Define configuration in config/initializers/rails_admin.rb:
|
22
22
|
|
23
23
|
RailsAdminImport.config do |config|
|
24
24
|
config.model User do
|
@@ -40,7 +40,7 @@ Installation
|
|
40
40
|
self.import_nested_data(row, map)
|
41
41
|
end
|
42
42
|
|
43
|
-
* "import" action must be added inside config.actions block in main application RailsAdmin configuration.
|
43
|
+
* "import" action must be added inside config.actions block in main application RailsAdmin configuration: config/initializers/rails_admin.rb.
|
44
44
|
|
45
45
|
config.actions do
|
46
46
|
...
|
@@ -48,11 +48,12 @@ Installation
|
|
48
48
|
...
|
49
49
|
end
|
50
50
|
|
51
|
+
Refer to [RailAdmin documentation on custom actions](https://github.com/sferik/rails_admin/wiki/Actions) that must be present in this block.
|
52
|
+
|
53
|
+
|
51
54
|
* TODO: Right now, import doesn't work for fields ending in s, because inflector fails in models ending in s singularly. Belongs_to and many
|
52
55
|
mapping needs to be updated to use klasses instead of symbols
|
53
56
|
|
54
|
-
Refer to RailAdmin documentation on custom actions that must be present in this block.
|
55
|
-
|
56
57
|
TODO
|
57
58
|
========
|
58
59
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
<% if @response -%>
|
2
2
|
<% if @response.has_key?(:error) -%>
|
3
|
-
<div class="alert-
|
3
|
+
<div class="alert-error alert">
|
4
4
|
<%= @response[:error] %>
|
5
5
|
</div>
|
6
6
|
<% end -%>
|
7
7
|
<% if @response.has_key?(:notice) -%>
|
8
|
-
<div class="alert-
|
8
|
+
<div class="alert-success alert">
|
9
9
|
<%= @response[:notice] %>
|
10
10
|
</div>
|
11
11
|
<% end -%>
|
@@ -74,6 +74,12 @@ module RailsAdminImport
|
|
74
74
|
else
|
75
75
|
map[key.to_sym] = i
|
76
76
|
end
|
77
|
+
end
|
78
|
+
|
79
|
+
update = params.has_key?(:update_if_exists) && params[:update_if_exists] ? params[:update_lookup].to_sym : nil
|
80
|
+
|
81
|
+
if update && !map.has_key?(params[:update_lookup].to_sym)
|
82
|
+
return results = { :success => [], :error => ["Your file must contain a column for the 'Update lookup field' you selected."] }
|
77
83
|
end
|
78
84
|
|
79
85
|
results = { :success => [], :error => [] }
|
@@ -88,8 +94,6 @@ module RailsAdminImport
|
|
88
94
|
|
89
95
|
label_method = RailsAdminImport.config(self).label
|
90
96
|
|
91
|
-
update = params.has_key?(:update_if_exists) && params[:update_if_exists] ? params[:update_lookup].to_sym : nil
|
92
|
-
|
93
97
|
file.each do |row|
|
94
98
|
object = self.import_initialize(row, map, update)
|
95
99
|
object.import_belongs_to_data(associated_map, row, map)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
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: 2012-
|
12
|
+
date: 2012-08-10 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: steph@endpoint.com
|