You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ gem "sprig"
16
16
```
17
17
Use `rails generate sprig:install` to create environment-specific and shared seed directories.
18
18
19
-
##The Sprig Directive
19
+
##The Sprig Directive
20
20
21
21
Within your seed file, you can use the `sprig` directive to initiate Sprig's dark magicks. A simple directive might look like this.
22
22
@@ -33,11 +33,11 @@ sprig_shared [User, Post, Comment]
33
33
34
34
This directive tells Sprig to go find your datafiles for the `User`, `Post`, and `Comment` seed resources, build records from the data entries, and insert them into the database. Sprig will automatically detect known datafile types like `.yml`, `.json`, or `.csv` within your environment-specific seed directory.
35
35
36
-
##Environment
36
+
##Environment
37
37
38
38
Seed files are unique to the environment in which your Rails application is running. Within `db/seeds` create an environment-specific directory (i.e. `/development` for your 'development' environment).
39
39
40
-
###Shared
40
+
###Shared
41
41
42
42
Shared seed files default directory is `shared` (eg `db/seeds/shared`)
43
43
You can change it by settings`
@@ -49,7 +49,7 @@ sprig_shared [User]
49
49
```
50
50
This will insert `:env/users` and `shared/users` seeds
51
51
52
-
##Seed files
52
+
##Seed files
53
53
54
54
Hang your seed definitions on a `records` key for *yaml* and *json* files.
55
55
@@ -159,7 +159,7 @@ records:
159
159
published_at: "<%= 1.week.ago %>"
160
160
```
161
161
162
-
##Custom Sources and Parsers
162
+
##Custom Sources and Parsers
163
163
164
164
If all your data is in `.wat` files, fear not. You can tell Sprig where to look for your data, and point it toward a custom parser class for turning your data into records. The example below tells Sprig to read `User` seed data from a Google Spreadsheet, and parse it accordingly.
165
165
@@ -179,7 +179,7 @@ sprig [
179
179
]
180
180
```
181
181
182
-
##Configuration
182
+
##Configuration
183
183
184
184
When Sprig conventions don't suit, just add a configuration block to your seed file.
0 commit comments