2014-01-05 48 views
0

嗨即時通訊做一個支付寶付款,反正當我更新的只是日期和積極的爲1,我沒有問題..更新列在不同的表,Rails3中

但是有一個活動列,在球員表(非用戶表)需要更新爲1,因爲它默認爲0。

如何才能做到這一點..因爲我得到「未定義的局部變量或方法'玩家」的#」

這裏是我的代碼

class PaymentNotification < ActiveRecord::Base 
    attr_accessible :player_id, :transaction_id, :params, :status, :active 

    belongs_to :user 
    belongs_to :player 
    serialize :params 
    after_create :mark_susc_as_purchased 

    private 

    def mark_susc_as_purchased 
    if status == "Completed" 
     user.update_attributes(:purchased_at => Time.now) 
     user.update_attributes(:active => 1) 
     player.update_attributes(:active => 1) 

    end 
    end 
end 

我的第一個猜測是:active必須我的東西其他像player.active ..但這劑量工作eitheir。

感謝

回答

0

這是現在工作

def mark_susc_as_purchased 
    if status == "Completed" 
     user.update_attributes(:purchased_at => Time.now) 
     user.update_attributes(:active => 1) 
     user.player.update_attributes(:active => 1) 
    end 
    end 
相關問題