# NoMethodError

**URL:** <https://www.ruby-forum.com/t/nomethoderror/114011>\
**Category:** Rails\
**Created:** [September 7, 2007, 4:05am UTC](https://www.ruby-forum.com/t/nomethoderror/114011 "2007-09-07T04:05:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df788c/32.png) [@jzhang](https://www.ruby-forum.com/u/jzhang)\
**Post date:** [September 7, 2007, 4:05am UTC](https://www.ruby-forum.com/t/nomethoderror/114011/1 "2007-09-07T04:05:57Z")

</div>

Rails guru

Our rails web applicaion always show NoMethodError after runing some  
time.

This NoMethodError throw from controller during the access to  
ActiveRecord association method. But we define a belongs\_to in the  
active record

Error happends on serveral pages, serveral controller and serveral  
active record

Version:  
ruby 1.8.4. Rails 1.1.4  
rails plugin into apache server (2.0.48) and fast\_cgi module ( probably  
2.4.2)

Thanks a lot

---

<div class="post-metadata">

**Author:** ![jzhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df788c/32.png) [@jzhang](https://www.ruby-forum.com/u/jzhang)\
**Post date:** [September 13, 2007, 10:12pm UTC](https://www.ruby-forum.com/t/nomethoderror/114011/2 "2007-09-13T22:12:31Z")

</div>

Jian Zhang wrote:

> Rails guru
> 
> Our rails web applicaion always show NoMethodError after runing some  
> time.
> 
> This NoMethodError throw from controller during the access to  
> ActiveRecord association method. But we define a belongs\_to in the  
> active record
> 
> Error happends on serveral pages, serveral controller and serveral  
> active record
> 
> Version:  
> ruby 1.8.4. Rails 1.1.4  
> rails plugin into apache server (2.0.48) and fast\_cgi module ( probably  
> 2.4.2)
> 
> Thanks a lot

More information

In a controller action, I switch to another db connection. The rest of  
controller use the default active record db connection. After I switch  
another db connection and then back, then NoMethodError happens. But I  
keep a separate db connection in subclass. Is rails cache active record  
action somewhere?. And I try to set config.cache\_classes and  
config.action\_controller.perform\_caching, still doesnt work.

Class AController \< ApplicationController  
def othermthods  
do\_B(args)  
end

class B \< ActiveRecord::Base # keep a separate db connection  
end

def do\_B(args)

```
B.establish_connection(
  :adapter => "mysql",
  :host => "xxxx",
  :username => "xxxx",
  :password => "xxxx",
  :database => "xxxx"
)

issues = B.connection.select_values("select ...");
B.connection.disconnect!

```

end  
end
