Currently `Application#config_for` raises an exception whenever a config file isn't found. However, this doesn't really seem very exceptional to me and there are going to be a lot of times where I want to configure an application module only if the configuration is available and something else if it isn't.
I could of course check if the file exists on my own, but then that almost entirely defeats the convenience of this convenience function. A few possible solutions: #### Offer an easy way to check if the file exists like `config_exists?` I don't like this because it feels too much like a nil checking pattern. #### Allow config_for to accept a block or argument This is similar to the `Hash#fetch` pattern, and the value of the block can be returned to the caller. The default exception behavior can remain if no value or block is provided. This would also allow for a few patterns. 1. Provide alternative configuration logic when the file isn't found 2. Don't configure the component when the file isn't found and log a warning For example: ``` if config_for(:the_thing, false) # configure the thing else # don't configure the thing logger.warn "The thing is not configured, no configuration file is found end ``` I'm definitely open to other suggestions, but the way `config_for` works right now I'm very hesitant to use it. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.
