Skip to content

Instantly share code, notes, and snippets.

@weatheredwatcher
Created May 26, 2010 01:02
Show Gist options
  • Save weatheredwatcher/413912 to your computer and use it in GitHub Desktop.
Save weatheredwatcher/413912 to your computer and use it in GitHub Desktop.
@contentsArray=[] #first we initialize an array for the contents
@fileArray =[] #then we initialize an array for the files
Dir.foreach("#{RAILS_ROOT}/public/posts") do |fname|
next if fname == '.' or fname == '..'
@fileArray.push fname
end
@fileArray = @fileArray.reverse #this insures that the blogs entries are listed in descending order
@fileArray.each{|file|
f = File.open("#{RAILS_ROOT}/public/posts/" + file, 'r')
f.each_line {|line|
@contentsArray.push line
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment