# Config.send()

**URL:** <https://www.ruby-forum.com/t/config-send/151801>\
**Category:** Rails\
**Created:** [October 26, 2008, 12:07am UTC](https://www.ruby-forum.com/t/config-send/151801 "2008-10-26T00:07:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [October 26, 2008, 12:07am UTC](https://www.ruby-forum.com/t/config-send/151801/1 "2008-10-26T00:07:14Z")

</div>

Any thoughts on why this in environment.rb will cause test:units to  
fail?

# Requires for application config (/config/config.yml)

require ‘ostruct’  
require ‘yaml’  
config = OpenStruct.new(YAML.load\_file("#{RAILS\_ROOT}/config/  
config.yml"))  
env\_config = config.send(RAILS\_ENV)  
config.common.update(env\_config) unless env\_config.nil?  
::AppConfig = OpenStruct.new(config.common)

It fails on:

env\_config = config.send(RAILS\_ENV)

With:

/home/thomas/src/entropic/config/environment.rb:18:in `test’: wrong  
number of arguments (ArgumentError)

–for the record, I snagged that bit of code off the web because I  
needed a nice way of getting “global” app config stuff in the app;  
having no experience with the “right” way of doing that in rails. For  
instance, with “AppConfig.app\_version” referencing the corresponding  
config.yml section…

–the alternative, I know, is to snazz it up and make a config model,  
storing stuff in the db. so don’t hesitate to leave 1995 alone and  
drop config.yml and do it in the db. 😉

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [October 26, 2008, 9:56am UTC](https://www.ruby-forum.com/t/config-send/151801/2 "2008-10-26T09:56:44Z")

</div>

join now

[http://rw2an.net/vb](http://rw2an.net/vb)

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [October 26, 2008, 10:09am UTC](https://www.ruby-forum.com/t/config-send/151801/3 "2008-10-26T10:09:16Z")

</div>

That’s because ENV\_RAILS is still nil at the time of execution of this  
piece of code. in environment.rb you can force it with: ENV[‘RAILS\_ENV’]  
||= ‘production’

---

<div class="post-metadata">

**Author:** ![tcsnide](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@tcsnide](https://www.ruby-forum.com/u/tcsnide)\
**Post date:** [October 27, 2008, 2:12pm UTC](https://www.ruby-forum.com/t/config-send/151801/4 "2008-10-27T14:12:34Z")

</div>

Oh joy, right. Thanks!

On Oct 26, 5:09 am, Fernando P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
