2017-08-04 172 views
1

我在我的應用程序中有一個計劃模型。有時我遇到以下錯誤。重新啓動服務器後,它會消失一段時間。PayPal-Ruby-SDK模型名稱衝突

寶石版本(1.6.0)

如何修復?

NoMethodError in Subscriptions#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' 

訂閱控制器索引操作

def index @plans = Plan.all end

Web控制檯

enter image description here

+0

您能否給我們實施您的計劃對象? – romainsalles

+0

@romainsalles它只有2行'has_many:subscriptions'和 'has_many:users,through::subscriptions'。這不是關於包含枚舉,因爲它在重新啓動服務器後工作正常。 – kirqe

+1

我不知道PayPal寶石。但看看文檔,我認爲你應該嘗試調用'Plan.all.members'或'Plan.all.to_hash'並看看你在那裏得到了什麼。因爲'Plan.all'不返回一個數組而是一個'PlanList'對象(@see:https://github.com/paypal/PayPal-Ruby-SDK/blob/master/lib/paypal-sdk/rest /data_types.rb#L2055) – romainsalles

回答

0

使用名稱空間而不是包含模塊可以解決問題。

PayPal::SDK::REST::Payment