我在我的應用程序中有一個用戶模型。現在我想在模塊用戶下將一些用戶模型編碼替換爲可能的employ.rb和customer.rb兩個類別,以避免單個模型中有更多數量的代碼。我想在用戶創建後訪問customer.rb中的send_mail方法。從rails中的其他模型訪問ruby中的實例方法?
user.rb
after_create:send_msg_on_order
def send_msg_on_order
Users::Customer.send_mail
end
用戶/ customer.rb
def send_mail
Mailer.send_mail_to_customer.deliver
end
而且我得到未定義的方法`send_mail」爲用戶::客戶:模塊錯誤。
如何m這些模型有哪些共同點?你使用sti嗎? – BroiSatse 2014-10-28 11:30:06