Dir.glob("*.jpg") {|_| puts 'hello'}
This works perfectly fine in IRB or a regular Rails script, but fails in Rails Console or a rails runner script. Which is irritating because I really need to use it. Google has no information on this that I can find. What's the deal?
Are there any JPG files in the root level of your app vs where you run ruby foo.rb
. I don't have any in mine, but if I tweak your code to this:
Dir.glob("**/*.jpg") {|_| puts _}
I get all of my jpg assets like I'd expect.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.