geetarista-export_csv 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -2
- data/lib/export_csv.rb +2 -2
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
== export_csv
|
2
2
|
|
3
|
-
Very simple tool to export all records of an ActiveRecord model
|
3
|
+
Very simple tool to export all records of an ActiveRecord model.
|
4
4
|
|
5
5
|
== Examples
|
6
6
|
|
7
|
+
The only required parameter is the model name:
|
8
|
+
|
7
9
|
export_csv(User)
|
8
|
-
export_csv(User, "User Backup", { :limit => 10 })
|
9
10
|
|
11
|
+
The name of the generated file can be overriden by passing it as a second option:
|
12
|
+
|
13
|
+
export_csv(User, "User Backup")
|
14
|
+
|
15
|
+
Find options may also be passed
|
16
|
+
|
17
|
+
export_csv(User, "User Backup", { :limit => 20 })
|
10
18
|
|
11
19
|
Copyright (c) 2009 Robby Colvin, released under the MIT license
|
data/lib/export_csv.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
def export_csv(klass, filename=klass, conditions=
|
1
|
+
def export_csv(klass, filename=klass, conditions={})
|
2
2
|
require 'ruport'
|
3
|
-
records = klass.find(:all, :
|
3
|
+
records = klass.find(:all, :options => options)
|
4
4
|
headers = klass.columns.collect{ |a| a.name }
|
5
5
|
data = []
|
6
6
|
records.each do |r|
|