# Critical \*weird\* error! :(

**URL:** <https://www.ruby-forum.com/t/critical-weird-error/107177>\
**Category:** Rails\
**Created:** [June 18, 2007, 8:20pm UTC](https://www.ruby-forum.com/t/critical-weird-error/107177 "2007-06-18T20:20:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 18, 2007, 8:20pm UTC](https://www.ruby-forum.com/t/critical-weird-error/107177/1 "2007-06-18T20:20:56Z")

</div>

user model  
has\_one :paying\_user, :dependent =\> :destroy

paying\_user model  
set\_primary\_key :user\_id  
belongs\_to :user  
has\_one :credit\_card, :foreign\_key =\> ‘user\_id’, :dependent  
=\> :destroy

> > > > I can load and print \<%= user.paying\_user.credit\_card %\> ONCE and it works, if I reload the page I got:

undefined method `credit\_card’ for #PayingUser:0xb7153378

log tail:

Processing MerchantController#rebill (for 127.0.0.1 at 2007-06-18  
18:05:56) [GET]  
Mon Jun 18 18:05:56 +0000 2007 (6124) Session ID:  
f752e7e5c586cefc81b62a352d0cf6a9  
Mon Jun 18 18:05:56 +0000 2007 (6124) Parameters:  
{“action”=\>“rebill”, “controller”=\>“merchant”}  
Mon Jun 18 18:05:56 +0000 2007 (6124) [4;35;1mUser Load Including  
Associations (0.016470) [0m [0mSELECT users.`id` AS t0\_r0,  
users.`username` AS t0\_r1, users.`email` AS t0\_r2, users.`firstname`  
AS t0\_r3, users.`lastname` AS t0\_r4, users.`gender_id` AS t0\_r5,  
users.`born_on` AS t0\_r6, users.`created_at` AS t0\_r7,  
users.`expires_on` AS t0\_r8, users.`roles` AS t0\_r9, users.`hobbies`  
AS t0\_r10, paying\_users.`user_id` AS t1\_r0, paying\_users.`firstname`  
AS t1\_r1, paying\_users.`lastname` AS t1\_r2, paying\_users.`email` AS  
t1\_r3, paying\_users.`address1` AS t1\_r4, paying\_users.`address2` AS  
t1\_r5, paying\_users.`city` AS t1\_r6, paying\_users.`state_province` AS  
t1\_r7, paying\_users.`postal_code` AS t1\_r8, paying\_users.`country` AS  
t1\_r9, paying\_users.`payment_type` AS t1\_r10,  
paying\_users.`phone_number` AS t1\_r11, paying\_users.`auto_renew` AS  
t1\_r12 FROM users LEFT OUTER JOIN paying\_users ON paying\_users.user\_id  
= users.id WHERE (expires\_on \< ‘2007-06-18’ AND expires\_on \<\>  
‘2007-06-23’ AND auto\_renew = 1) ORDER BY expires\_on DESC [0m

Mon Jun 18 18:05:56 +0000 2007 (6124) [4;36;1mUser Load Including  
Associations (0.000212) [0m [0;1mSELECT users.`id` AS t0\_r0,  
users.`username` AS t0\_r1, users.`email` AS t0\_r2, users.`firstname`  
AS t0\_r3, users.`lastname` AS t0\_r4, users.`gender_id` AS t0\_r5,  
users.`born_on` AS t0\_r6, users.`created_at` AS t0\_r7,  
users.`expires_on` AS t0\_r8, users.`roles` AS t0\_r9, users.`hobbies`  
AS t0\_r10, paying\_users.`user_id` AS t1\_r0, paying\_users.`firstname`  
AS t1\_r1, paying\_users.`lastname` AS t1\_r2, paying\_users.`email` AS  
t1\_r3, paying\_users.`address1` AS t1\_r4, paying\_users.`address2` AS  
t1\_r5, paying\_users.`city` AS t1\_r6, paying\_users.`state_province` AS  
t1\_r7, paying\_users.`postal_code` AS t1\_r8, paying\_users.`country` AS  
t1\_r9, paying\_users.`payment_type` AS t1\_r10,  
paying\_users.`phone_number` AS t1\_r11, paying\_users.`auto_renew` AS  
t1\_r12 FROM users LEFT OUTER JOIN paying\_users ON paying\_users.user\_id  
= users.id WHERE (expires\_on = ‘2007-06-18’ AND auto\_renew = 1) ORDER  
BY expires\_on DESC [0m  
Mon Jun 18 18:05:56 +0000 2007 (6124) Rendering within layouts/  
application  
Mon Jun 18 18:05:56 +0000 2007 (6124) Rendering merchant/rebill  
Mon Jun 18 18:05:56 +0000 2007 (6124)

ActionView::TemplateError (undefined method `credit\_card’ for  
#PayingUser:0xb7153378) on line #15 of app/views/merchant/  
rebill.rhtml:  
12:  
13:

- user: \<%= user.username %\> on \<%= user.expires\_on %\>  
14:  
15: \<% user.auth().message %\>  
16:  
17: \<%= user.paying\_user.credit\_card %\>  
18:

```
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/

```

base.rb:1860:in `method_missing' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/ associations/association_proxy.rb:123:in`send’  
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/  
associations/association\_proxy.rb:123:in `method_missing' #{RAILS_ROOT}/app/models/user.rb:161:in`format\_credit\_card’  
#{RAILS\_ROOT}/app/models/user.rb:234:in `auth' #{RAILS_ROOT}/app/views/merchant/rebill.rhtml:15:in`\_run\_rhtml\_47app47views47merchant47rebill46rhtml’  
#{RAILS\_ROOT}/app/views/merchant/rebill.rhtml:11:in `each' #{RAILS_ROOT}/app/views/merchant/rebill.rhtml:11:in`\_run\_rhtml\_47app47views47merchant47rebill46rhtml’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_view/  
base.rb:326:in `send' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/ base.rb:326:in`compile\_and\_render\_template’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_view/  
base.rb:301:in `render_template' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/ base.rb:260:in`render\_file’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/base.rb:806:in `render_file' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/base.rb:711:in`render\_with\_no\_layout’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/layout.rb:247:in `render_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/benchmarking.rb:50:in`render’  
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/benchmarking.rb:50:in`render’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/base.rb:1096:in `perform_action_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:632:in`call\_filter’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/filters.rb:638:in `call_filter' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:438:in`call’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/filters.rb:637:in `call_filter' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:638:in`call\_filter’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/filters.rb:438:in `call' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:637:in`call\_filter’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/filters.rb:638:in `call_filter' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:438:in`call’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/filters.rb:637:in `call_filter' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:638:in`call\_filter’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/filters.rb:438:in `call' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:637:in`call\_filter’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/filters.rb:638:in `call_filter' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:449:in`call’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/filters.rb:637:in `call_filter' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:619:in`perform\_action\_without\_benchmark’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/benchmarking.rb:66:in  
`perform_action_without_rescue' /usr/lib/ruby/1.8/benchmark.rb:293:in`measure’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/benchmarking.rb:66:in  
`perform_action_without_rescue' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/rescue.rb:83:in`perform\_action’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/base.rb:430:in `send' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/base.rb:430:in`process\_without\_filters’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/filters.rb:624:in  
`process_without_session_management_support' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/session_management.rb:114:in`process’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/  
action\_controller/base.rb:330:in `process' /usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in`dispatch’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:  
78:in `process' /usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb: 76:in`synchronize’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:  
76:in `process' /usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:618:in`process\_client’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in  
`each' /usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in`process\_client’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in  
`run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in`initialize’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in  
`new' /usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in`run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in  
`initialize' /usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in`new’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in  
`run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/ configurator.rb:271:in`run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/  
configurator.rb:270:in `each' /usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/ configurator.rb:270:in`run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel\_rails:127:in  
`run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/command.rb: 211:in`run’  
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel\_rails:243  
/usr/bin/mongrel\_rails:16:in `load’  
/usr/bin/mongrel\_rails:16

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 19, 2007, 1:36am UTC](https://www.ruby-forum.com/t/critical-weird-error/107177/2 "2007-06-19T01:36:08Z")

</div>

Emanuele Mek Tozzato wrote:

> > > > > I can load and print \<%= user.paying\_user.credit\_card %\> ONCE and it works, if I reload the page I got:
> 
> undefined method `credit\_card’ for #PayingUser:0xb7153378

Which OS, database, and database adapter are you using?

–  
We develop, watch us RoR, in numbers too big to ignore.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 19, 2007, 2:13am UTC](https://www.ruby-forum.com/t/critical-weird-error/107177/3 "2007-06-19T02:13:11Z")

</div>

thanks for asking!

I’m sandboxing on ubuntu feisty, nginx and mongrel… so the issue is  
only on personal localhost, productions servers work ok… application  
uses libevent, sesstrack and memcached and problems started when using  
xml for page caching… db is mysql.

# Allow xml\_request to work with page caching

map.connect ‘xml/  
query/:controller/:action/:cat/:sub/:page’, :xml\_request =\> ‘1’  
map.connect ‘xml/:controller/:action/:id’, :xml\_request =\> ‘1’

this error is driving me crazy…

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 19, 2007, 1:03pm UTC](https://www.ruby-forum.com/t/critical-weird-error/107177/4 "2007-06-19T13:03:18Z")

</div>

Emanuele Mek Tozzato wrote:

> this error is driving me crazy…  
> I had a similar error that turned out to be a problem with the  
> pure Ruby DB bindings, fixed by moving to the C bindings.

But in your case it may be a memcached issue.

–  
We develop, watch us RoR, in numbers too big to ignore.
