Hi, folks --
Sorry if this has been discussed ad infinitum but I've been searching and testing for hours and I'm not getting anywhere
My Ruby is ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] on Ubuntu 18.4
I created a bunch of files using a Rails generator (5.2.2) but since 'rails g' can't utilize all the options a migration file is capable of. I need to change_column and add_column and then re-write the file.
Here's the pertinent part of the modification program:
<code>
add_files.each do | add_file |
add_file.chomp
file_str = "/home/din/Projects/DLC/rails_server/product_exchange/db/migrate/" + add_file
puts "exist"
puts File.exist?(file_str)
puts "ls"
ls_str = "ls -al " + file_str
system(ls_str)
puts "read:"
puts File.readable?(file_str)
puts "write:"
puts File.writable?(file_str)
File.open(file_str, "r+") do | the_add_file |
# ...
end
</code>
Here's the result:
<execute>
$ populate_user_table_migrations_01.rb
exist
false
ls
-rw-rw-rw- 1 din din 90 Jan 21 13:11 /home/din/Projects/DLC/rails_server/product_exchange/db/migrate/20190119232341_add_columns_to_alabama_users_table.rb
read:
false
write:
false
Traceback (most recent call last):
4: from /home/din/Projects/DLC/code_ruby/populate_user_table_migrations_01.rb:5:in `<main>'
3: from /home/din/Projects/DLC/code_ruby/populate_user_table_migrations_01.rb:5:in `each'
2: from /home/din/Projects/DLC/code_ruby/populate_user_table_migrations_01.rb:17:in `block in <main>'
1: from /home/din/Projects/DLC/code_ruby/populate_user_table_migrations_01.rb:17:in `open'
/home/din/Projects/DLC/code_ruby/populate_user_table_migrations_01.rb:17:in `initialize': No such file or directory @ rb_sysopen - /home/din/Projects/DLC/rails_server/product_exchange/db/migrate/20190119232341_add_columns_to_alabama_users_table.rb (Errno::ENOENT)
</execute>
Now, as you can see from the output of the ls -al command, the file is there, and it's readable and writable. The db/migrate directory is also writable by world, but none of the tests find it and it blows up on File.open. I'm running the updater from inside db/migrate, although as you can see the updater now has hard-coded paths everywhere.
Please, somebody tell me this is something trivial and silly! :)
I've tried various IO combinations, various File.open combinations, etc, and I've been googling all morning and part of yesterday.
Thanks in advance!