ruby-on-rails - PayPal-Ruby-SDK 模型名称冲突

标签 ruby-on-rails ruby paypal paypal-rest-sdk

我的应用程序中有一个计划模型。有时我会遇到以下错误。重新启动服务器后,它会消失一段时间。

gem 版本(1.6.0)

如何修复?

订阅中没有方法错误#index

undefined method `map' for #<PayPal::SDK::REST::DataTypes::PlanList:0x007fbc494c13c0>
Did you mean?  tap

--

  Rendering subscriptions/index.html.erb within layouts/application
  Rendered subscriptions/index.html.erb within layouts/application (3.3ms)
Completed 500 Internal Server Error in 2145ms (ActiveRecord: 8.3ms)



ActionView::Template::Error (undefined method `map' for #<PayPal::SDK::REST::DataTypes::PlanList:0x007fbc494c13c0>
Did you mean?  tap):
     7:       <div class="field">
     8:         <p class="control has-icons-left is-expanded">
     9:           <%= form.input_field :plan_id,
    10:            collection: @plans.map {|plan| ["#{plan.name} - $#{plan.cost}", plan.id]},
    11:            wrapper_html: { class: ' select is-fullwidth' }, class: 'input', label: false, prompt: 'Select a plan' %>
    12:           <span class="icon is-small is-left">
    13:             <i class="fa fa-bars"></i>

app/views/subscriptions/index.html.erb:10:in `block in _app_views_subscriptions_index_html_erb___836818763133109538_70223330120860'
app/views/subscriptions/index.html.erb:2:in `_app_views_subscriptions_index_html_erb___836818763133109538_70223330120860'

订阅 Controller 索引操作

定义索引 @plans = 计划.all 结尾

网络控制台

enter image description here

最佳答案

使用命名空间而不是包含模块可以解决问题。

PayPal::SDK::REST::Payment

关于ruby-on-rails - PayPal-Ruby-SDK 模型名称冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45507303/

相关文章:

ruby-on-rails - 创建新的 Rails 应用程序时,为什么会出现 Gemfile.lock 文件而不运行 bundle 安装?

ruby-on-rails - "DateTime.beginning_of_week => :monday"但 "DateTime.current.wday == 0"是星期日

ruby-on-rails - 环境变量返回 nil

ruby-on-rails - 如何按原始顺序获取 POST 参数(使用 Rails)?

php - 重定向后立即出现 Paypal IPN 确认屏幕,无需重新加载

paypal - 将 PayPal Credit 选项添加到 PayPal 按钮

ruby-on-rails - Prawn 不会画横线

ruby - 如何在 CentOS 6.9 上安装 Ruby?

ruby - 如何使用 Ruby 从本地 heroku 生产数据库中将表导出到控制台中的 excel?

paypal - 退订链接带有企业电子邮件而不是商家 ID