This is a simple way to load text as part of your rake db:seed task..
The following code will load all the files you have in a directory called doc/pages. In this case I have used the .textile extension.
In db/seeds.rb:
Dir.glob("#{Rails.root}/doc/pages/*.textile") do |file| Page.create(:permalink => File.basename(file, '.textile').downcase, :title => File.basename(file, '.textile').titleize, :body => File.read(file), :published => true) end
doc/pages/about_us.textile will be saved with a permalink of ‘about_us’ and a title of “About Us”.
@roxannedarling @shane on Maui #hipstamatic
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Hiking | |
| Event Type: | Recreation | |
| Distance: | 2.63 Mile | |
| Time: | 00:55:00 | |
| Elevation Gain: | 630 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Snowshoeing | |
| Event Type: | Recreation | |
| Distance: | 2.46 Mile | |
| Time: | 01:52:21 | |
| Elevation Gain: | 636 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Running | |
| Event Type: | Uncategorized | |
| Distance: | 3.85 Mile | |
| Time: | 01:24:34 | |
| Elevation Gain: | 875 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Trail Running | |
| Event Type: | Fitness | |
| Distance: | 4.79 Mile | |
| Time: | 00:49:53 | |
| Elevation Gain: | 595 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Trail Running | |
| Event Type: | Recreation | |
| Distance: | 4.77 Mile | |
| Time: | 00:49:58 | |
| Elevation Gain: | 612 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Trail Running | |
| Event Type: | Fitness | |
| Distance: | 7.05 Mile | |
| Time: | 01:09:49 | |
| Elevation Gain: | 653 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Hiking | |
| Event Type: | Recreation | |
| Distance: | 3.66 Mile | |
| Time: | 01:05:47 | |
| Elevation Gain: | 777 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Hiking | |
| Event Type: | Recreation | |
| Distance: | 1.29 Mile | |
| Time: | 00:31:01 | |
| Elevation Gain: | 305 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Hiking | |
| Event Type: | Recreation | |
| Distance: | 0.95 Mile | |
| Time: | 00:21:34 | |
| Elevation Gain: | 210 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Hiking | |
| Event Type: | Recreation | |
| Distance: | 1.50 Mile | |
| Time: | 00:35:42 | |
| Elevation Gain: | 357 Feet | |