Critical *weird* error! :(

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:insend’
    /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:informat_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:incompile_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:inrender_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:inrender_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:inrender’
    /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:inrender’
    /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:incall_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:incall’
    /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:incall_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:incall_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:incall’
    /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:incall_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:incall_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:incall’
    /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:inperform_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:inmeasure’
    /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:inperform_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:inprocess_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:inprocess’
    /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:indispatch’
    /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:insynchronize’
    /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:inprocess_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:inprocess_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:ininitialize’
    /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:inrun’
    /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:innew’
    /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:inrun’
    /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:inrun’
    /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:inrun’
    /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

  • 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.

    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…

    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.