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: | Mountain Biking | |
| Event Type: | Recreation | |
| Distance: | 4.69 Mile | |
| Time: | 00:52:03 | |
| Elevation Gain: | 874 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Hiking | |
| Event Type: | Recreation | |
| Distance: | 3.26 Mile | |
| Time: | 01:18:56 | |
| Elevation Gain: | 715 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Trail Running | |
| Event Type: | Training | |
| Distance: | 5.40 Mile | |
| Time: | 01:14:22 | |
| Elevation Gain: | 1,226 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Mountain Biking | |
| Event Type: | Recreation | |
| Distance: | 20.69 Mile | |
| Time: | 02:46:55 | |
| Elevation Gain: | 2,202 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Trail Running | |
| Event Type: | Training | |
| Distance: | 5.40 Mile | |
| Time: | 01:08:31 | |
| Elevation Gain: | 1,231 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Mountain Biking | |
| Event Type: | Recreation | |
| Distance: | 7.93 Mile | |
| Time: | 00:57:42 | |
| Elevation Gain: | 827 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Trail Running | |
| Event Type: | Training | |
| Distance: | 9.27 Mile | |
| Time: | 01:57:40 | |
| Elevation Gain: | 1,979 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Trail Running | |
| Event Type: | Training | |
| Distance: | 5.39 Mile | |
| Time: | 01:10:15 | |
| Elevation Gain: | 1,237 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Mountain Biking | |
| Event Type: | Recreation | |
| Distance: | 11.01 Mile | |
| Time: | 01:44:13 | |
| Elevation Gain: | 1,988 Feet | |
| Owner: | c.nick | |
| Location: | -- | |
| Activity Type: | Trail Running | |
| Event Type: | Training | |
| Distance: | 8.93 Mile | |
| Time: | 01:52:09 | |
| Elevation Gain: | 2,060 Feet | |