ruby-on-rails - 如何从复杂的模块(paypal_permissions gem)中包含类?

标签 ruby-on-rails module paypal

已编辑

对不起,没有发布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/

相关文章:

ruby-on-rails - 添加购物车项目 Ruby on Rails

import - 如何将一个文件夹中的文件导入到rust中另一个文件夹中的文件中?

c# - C# 中的类和模块是什么

Grails Paypal SDK 集成

forms - 带有 paypal 表单的 WordPress Metabox 或者我可以添加一个链接吗?

html - PayPal 代码在我为选项添加价格之前有效吗?

ruby-on-rails - PostgreSQL 服务无法停止/启动/重启

java - 为什么 JRuby 不能识别 BigNums 而 Ruby 可以?

Netbeans 中的 Python 引用外部模块

ruby-on-rails - 当我将 "multiple true"添加到 collection_select 时,Rails 4 HABTM 停止工作