开发者

File not appearing in Heroku - Browsing Heroku Contents

开发者 https://www.devze.com 2023-01-28 13:49 出处:网络
I\'m running an application on heroku - it appears to function just fine and I am able to access my database. Now, I am attempting to run \'heroku rake db:seed\'...which runs, until it reaches this po

I'm running an application on heroku - it appears to function just fine and I am able to access my database. Now, I am attempting to run 'heroku rake db:seed'...which runs, until it reaches this point in my code;

  composersInput = IO.readlines("app\\data\\composers.txt")
  composersInput.length.times do |i|
  name, borndied, nationality, style, gender = composersInput[i].split(':')
  yearBorn, yearDied = borndied.split('-')
  Composer.create!(:name => name, :year_born => yearBorn.to_i, :year_died => yearDied.to_i,
                   :nationality_id => nationality.to_i, :style_id => style.to_i, :gender => gender)
end

When it tries to load the composers.txt I receive the following error "No such file or directory - app\data\composers.txt", and I am incredibly clueless as to why. This code works fine for my local copy and executes with no problem - I have verified that the file compos开发者_运维问答ers.txt is indeed inside that directory on my machine, and I verified that they are being included in the git push to heroku.

I am wondering if there's something wrong w. my IO syntax? Is there a way for me to browse the file structure of my heroku app so I can verify that the file is indeed there? If you have any advice, it would be much appreciated :)


heroku console is your friend.

keith@Lucy:~/code/paperhat (master)$ heroku console
Ruby console for somesite.heroku.com
>> `ls .`
=> "Gemfile\nGemfile.lock\nREADME\nRakefile\napp\nconfig\ndb\nfeatures\ngenerate\nlib\nlog\npublic\nscript\nspec\ntmp\nvendor\n"

its not awesome in terms of formatting, but you can at least poke around on your heroku slug and see what's going on. Incidentally, I'd probably use the following to get to your config file instead of what you've got:

Rails.root.join("app", "data", "composers.txt")


heroku console is no longer supported, instead one must use "heroku run COMMAND", i.e.

$ heroku run 'ls .'

Note that here these are single (or double) quotes, NOT the backtics as used in heroku console. If the backticks are used (heroku run ls), then the ls command gets run locally first and then feeds the list of filenames to heroku run as the COMMAND to be run...

If you have more than one heroku app in your project, such as production and staging, you may need to specify the app to target (find the app name in your .git/config file, or run "heroku apps"):

$ heroku run 'ls -al .' --app awesome-newsom-1234
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号