I''m trying to DRY up my database.yml file. At first I tried settign some variables in my environment.rb to use in the database.yml, but it doesnt seem that the environment.rb variables are available to the Erb that gets run on the database.yml (at least not during rake). So now I am trying to use an alias to name my databases, but there is really REALLY bad documentation on aliases/anchors in YAML, at lease if you google it. And whatever I did figure out doesn''t seem to work. So I want to replace *app in the following with the folder name for the rails app. Ie. say I did ''rails newapp'', I would want my databases to be named newapp_dev, newapp_test, and newapp_prod. But I dont want to have to change it in 3 places in the database.yml. I don;t want to change it all in the database yml, but it seems that the alternative would be to put a bunch of ENV variables on the commandline (ie. the ones in environment.rb dont work). Here is my database.yml: login: &login adapter: mysql username: interact password: mediaugen host: localhost development: <<: *login database: *app_dev test: <<: *login database: *app_test production: <<: *login database: *app_prod So I want to have ''*app'' replaced with ''newapp''. I''ve tried - &app "fanatics" &app "fanatics" app: - &app "fanatics" app: &app "fanatics" to set my alias, but none of these seem to work. What am I doing wrong? Is the an intelligable reference for yaml that shows how to use anchors this way? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Slain Wilde wrote:> I''ve tried > > - &app "fanatics" > &app "fanatics" > app: - &app "fanatics" > app: &app "fanatics"That should be: - &app "newapp" &app "newapp" app: - &app "newapp" app: &app "newapp" as well as - &app newapp -&app newapp &app newapp app: - &app newapp app: &app newapp -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 3, 2006, at 10:30 PM, Slain Wilde wrote:> So I want to replace *app in the following with the folder name for > the > rails app. Ie. say I did ''rails newapp'', I would want my > databases to > be named newapp_dev, newapp_test, and newapp_prod. But I dont want to > have to change it in 3 places in the database.yml. I don;t want to > change it all in the database yml, but it seems that the alternative > would be to put a bunch of ENV variables on the commandline (ie. the > ones in environment.rb dont work).> So I want to have ''*app'' replaced with ''newapp''. > > I''ve tried > > - &app "fanatics" > &app "fanatics" > app: - &app "fanatics" > app: &app "fanatics" > > to set my alias, but none of these seem to work. > > What am I doing wrong? Is the an intelligable reference for yaml that > shows how to use anchors this way?I''m no YAML expert but I think when you use "database: *app_prod" it will be looking for %app_prod to be defined somewhere, and isn''t going to pick up on &app. You can however use erb in your YAML like so: production: <<: &login database: <%= puts ''#{app_name}_prod''%> -- Craig Beck AIM: kreiggers --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---