私は Rails 3 用のテンプレートを作成しています (ここで見つけることができます)。次の行で問題が発生しています。
# 8. config/database.yml modifications
if yes?("Do you want to set the database host to '/var/run/postgresql'?")
inject_into_file "config/database.yml", " host: /var/run/postgresql\n", :after => "development:\n"
# FIXME these two won't work :(((( why????
# inject_into_file "config/database.yml", " host: /var/run/postgresql\n", :after => "production:\n"
# inject_into_file "config/database.yml", " host: /var/run/postgresql\n", :after => "test:\n"
# Not finding other solutions, I rewrite the two blocks above with two seds
run %q(sed -i '/test:/a\ \ host: /var/run/postgresql' config/database.yml)
run %q(sed -i '/production:/a\ \ host: /var/run/postgresql' config/database.yml)
end
つまり、最初の inject_to_file が機能し、config/database.yml に
development:
host: /var/run/postgresql
他の 2 つの inject_to_file は正常に適用されますが、config/database.yml を変更しないでください。ので、私は持っています
test:
adapter: postgresql
と
production:
adapter: postgresql