【发布时间】:2014-11-07 15:00:29
【问题描述】:
我正在尝试将 PayPal 电子支付添加到我的 RoR 应用程序中。所以我继续如下: 我的 panier.rb:
class Panier < ActiveRecord::Base
belongs_to :user
def paypal_url(return_path)
values = {
:business => 'r.karoui-buyer@loganddrive.com',
:cmd => '_cart',
:upload => 1,
:return => return_path,
:invoice => id
}
line_items.each_with_index do |item, index|
values.merge!({
"amount_#{index+1}" => item.price,
"item_name_#{index+1}" => item.book.title,
"item_number_#{index+1}" => item.id,
"quantity_#{index+1}" => 1
})
end
"#{Rails.application.secrets.paypal_host}/cgi-bin/webscr?" + values.to_query
end
end
我的 details.html.erb:我在哪里调用 PayPal 服务
<%= @panier.book_id %> | <%= @panier.price %> | <%= link_to 'acheter' , @panier.paypal_url(paniers_path) %>
但我收到了这个错误:
用于#的未定义局部变量或方法`line_items'
我只是遵循这个 railsCast 教程:
我应该用什么代替 line_items.each_with_index do |item, index|如果这里是错误,如果不是,请帮助我找出问题所在
【问题讨论】: