# Recognition\_conditions called before overridden from environment.rb

**URL:** <https://www.ruby-forum.com/t/recognition-conditions-called-before-overridden-from-environment-rb/165372>\
**Category:** Rails\
**Created:** [April 13, 2009, 10:37am UTC](https://www.ruby-forum.com/t/recognition-conditions-called-before-overridden-from-environment-rb/165372 "2009-04-13T10:37:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hideaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/87869e/32.png) [@hideaki](https://www.ruby-forum.com/u/hideaki)\
**Post date:** [April 13, 2009, 10:37am UTC](https://www.ruby-forum.com/t/recognition-conditions-called-before-overridden-from-environment-rb/165372/1 "2009-04-13T10:37:50Z")

</div>

Hi!  
I just updated rails 2.0.2 to 2.2.2 and noticed that my overriding  
ActionController::Routing::Route#recognition\_conditions does not work  
as expected anymore.  
I was overriding the method from environment.rb, but I found that the  
method is called before  
my overriding takes place. So, it is executed without my  
customization…  
Does anyone have any remedy for that?  
Thank you,  
-Hideaki Hayashi

---

<div class="post-metadata">

**Author:** ![hideaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/87869e/32.png) [@hideaki](https://www.ruby-forum.com/u/hideaki)\
**Post date:** [April 13, 2009, 10:41am UTC](https://www.ruby-forum.com/t/recognition-conditions-called-before-overridden-from-environment-rb/165372/2 "2009-04-13T10:41:56Z")

</div>

On Apr 13, 8:36 am, hideaki [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi!  
> I just updated rails 2.0.2 to 2.2.2 and noticed that my overriding  
> ActionController::Routing::Route#recognition\_conditions does not work  
> as expected anymore.  
> I was overriding the method from environment.rb, but I found that the  
> method is called before  
> my overriding takes place. So, it is executed without my  
> customization…  
> Does anyone have any remedy for that?

As of rails 2.2, a bunch of stuff is loaded during startup (rather  
than on demand in production (because loading it on demand isn’t  
thread safe). As a general rule, things that you could keep at the  
bottom of environment.rb should now be in initializers (see  
[environment.rb and requiring dependencies - Space Vatican](http://www.spacevatican.org/2008/11/21/environment-rb-and-requiring-dependencies))

Fred
