Josef Wolf wrote:
> Hello folks,
> 
> I'd like to use postgresql with unix domain sockets for 
> testinng/development
> to avoid mismatches when tests from multiple working copies are run
> concurrently.
> 
> I can almost get what I want with the following entry in 
> config/database.yml:
> 
>   test:
>     adapter: postgresql
>     encoding: unicode
>     database: testapp_test
>     username:
>     password:
>     host: /home/ruby/rails/testapp/db/pgdata
> 
> Unfortunately, the path is specified absolutely here.  So when I check 
> out
> two working copies of my application and run the tests in parallel on 
> both
> copies, the database will get mangled.
> 
> So I am looking for a possibility to specify the directory relatively.
> Maybe
> 
>     host: `pwd`/db/pgdata
> 
> or
> 
>     host: #{RAILS_DIR}/db/pgdata
> 
> or something.
> 
> Can this (or something similar) be done?  Any suggestions?

Since config/database.yml is read through ERB, you can do stuff like


host: <%= RAILS_DIR %>/db/pgdata


or


host: <%= `hostname` %>


Check vendor/rails/railties/lib/initializer.rb, this is from Rails 2.3:

    # Loads and returns the contents of the 
#database_configuration_file. The
    # contents of the file are processed via ERB before being sent 
through
    # YAML::load.
    def database_configuration
      require 'erb'
      YAML::load(ERB.new(IO.read(database_configuration_file)).result)
    end



-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to