csv_rails 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +6 -0
- data/lib/csv_rails/active_record.rb +2 -2
- data/lib/csv_rails/version.rb +1 -1
- data/test/csv_rails/active_record_test.rb +4 -0
- data/test/dummy/app/models/group.rb +4 -0
- data/test/dummy/config/locales/ja.yml +5 -0
- data/test/dummy/log/test.log +5975 -0
- metadata +6 -8
- data/test/dummy/tmp/pids/server.pid +0 -1
data/README.rdoc
CHANGED
@@ -68,9 +68,15 @@ If you do not use :header option, header is using :fields and I18n transfer.
|
|
68
68
|
name: 名前
|
69
69
|
age: 年齢
|
70
70
|
ok: OK
|
71
|
+
# rails3
|
71
72
|
groups:
|
72
73
|
first:
|
73
74
|
<<: *groupmodel
|
75
|
+
# edge rails
|
76
|
+
user/groups:
|
77
|
+
first:
|
78
|
+
<<: *groupmodel
|
79
|
+
|
74
80
|
|
75
81
|
# app/controllers/user_controller.rb
|
76
82
|
def index
|
@@ -34,8 +34,8 @@ module CsvRails
|
|
34
34
|
field.to_s.split(".").inject(self){|object, f|
|
35
35
|
next unless object
|
36
36
|
convert_method = "#{f}_as_csv"
|
37
|
-
method = respond_to?(convert_method) ? convert_method : f
|
38
|
-
object.send(
|
37
|
+
method = object.respond_to?(convert_method) ? convert_method : f
|
38
|
+
object.send(method)
|
39
39
|
}
|
40
40
|
}
|
41
41
|
end
|
data/lib/csv_rails/version.rb
CHANGED
@@ -88,4 +88,8 @@ class CsvRails::ActiveRecordTest < ActiveSupport::TestCase
|
|
88
88
|
assert_equal csv, User.includes(:groups).to_csv(:fields => [:name, :"groups.first.name"])
|
89
89
|
I18n.locale = :en
|
90
90
|
end
|
91
|
+
|
92
|
+
test ".to_csv with association using as_csv" do
|
93
|
+
assert_equal @group.created_at_as_csv, User.includes(:groups).to_csv(:fields => [:"groups.first.created_at"], :without_header => true).chomp
|
94
|
+
end
|
91
95
|
end
|