put
phương pháp không còn hoạt động tại Capistrano 3
Giải pháp này làm việc cho tôi
task :generate_yml do
on roles(:app) do
set :db_username, ask("DB Server Username", nil)
set :db_password, ask("DB Server Password", nil)
db_config = <<-EOF
development:
database: #{fetch(:application)}_development
adapter: mysql2
encoding: utf8
reconnect: false
pool: 5
username: #{fetch(:db_username)}
password: #{fetch(:db_password)}
test:
database: #{fetch(:application)}_test
adapter: mysql2
encoding: utf8
reconnect: false
pool: 5
username: #{fetch(:db_username)}
password: #{fetch(:db_password)}
production:
database: #{fetch(:application)}_production
adapter: mysql2
encoding: utf8
reconnect: false
pool: 5
username: #{fetch(:db_username)}
password: #{fetch(:db_password)}
EOF
location = fetch(:template_dir, "config/deploy") + '/database.yml'
execute "mkdir -p #{shared_path}/config"
File.open(location,'w+') {|f| f.write db_config }
upload! "#{location}", "#{shared_path}/config/database.yml"
end
end
là "đặt" tạo ra file mới? Và nếu không: Nó có ghi đè tệp hoặc nối thêm vào tệp đó không? – user1291365
Xem các tài liệu Capistrano cho một lời giải thích của 'put' – zetetic
này không còn hoạt động như của Capistrano v3 – rposborne