已编辑
对不起,没有发布ALL
我的 Controller :
def get_basic_personal_data merchant
access_token = merchant.ppp_access_token
verifier = merchant.ppp_access_token_verifier
::PAYPAL_PERMISSIONS_GATEWAY.get_basic_personal_data(access_token, verifier)
end
我有模块:
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class PaypalPermissionsGateway < ActiveMerchant::Billing::Gateway # :nodoc
...
def get_basic_personal_data
...
end
我需要使用这个方法从PayPal获取数据,所以我需要将它包含到merchant_controller中,但我不知道如何。
我想在 View 中使用如下内容:
<%= @merchant.get_basic_personal_data.email%>
但我经常出错:
undefined method `get_basic_personal_data' for #<Merchant:0x618ea78>
编辑
完整跟踪的错误:
activemodel (3.2.3) lib/active_model/attribute_methods.rb:407:in `method_missing'
activerecord (3.2.3) lib/active_record/attribute_methods.rb:148:in `method_missing'
我该怎么办?
最佳答案
在您的模型的顶部,使用 include ActiveMerchant::Billing
加载模块,然后您应该能够执行 @merchant.get_basic_personal_data
。
关于ruby-on-rails - 如何从复杂的模块(paypal_permissions gem)中包含类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11504170/