Forum: Ruby on Rails Load and Save data in yaml file in capistrano

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Arthur C. (Guest)
on 2009-02-16 15:02
Hi All,

I tried to request user to input username and password for the database
when deploy, therefore, in my capistrano task, I

    task :create_database_user do
      @username = Capistrano::CLI.password_prompt('mysql_username: ')
      @password = Capistrano::CLI.password_prompt('mysql_password: ')

      #@config = YAML::load(
      @config["username"] = @username
      @config["password"] = @password


However, File not found error occurs.

Actually, I want to save the input in the .yml file so that I can access
them before restart in the database.yml.

Or, Can I save the cap input into the database.yml directly before

How can I do that?

Thanks much!
Jeff E. (Guest)
on 2009-02-17 02:15
(Received via mailing list)
Did you mean

instead of

On Feb 16, 8:02 am, Arthur C. <removed_email_address@domain.invalid>
Arthur C. (Guest)
on 2009-02-17 03:21
Jeff Emminger wrote:
> Did you mean
> "#{release_path}/config/database.yml"
> instead of
> "#{release_path}/config/config.yml"
> On Feb 16, 8:02�am, Arthur C. <removed_email_address@domain.invalid>

Yes and no. I wanna update the database.yml. But the main reason I do
this task is to protect the password, so I should not write anything
there. Instead, I wanna create an object to hold the MYSQL login and put
it in the database.yml:

  adapter: mysql
  database: arthur_dev
  username: <%= username %>
  password: <%= password %>

The problem is in Capistrano that I don't know how to retrieve the
password from Capistrano
"Capistrano::CLI.password_prompt('mysql_username: ')".

Thanks much!
This topic is locked and can not be replied to.