【发布时间】:2015-05-26 05:44:24
【问题描述】:
我想将 PayPal 支付系统添加到我的 RoR 应用。为此,我确实安装了paypal-sdk-rest gem。
我有一个模型 Feed 和 index.html.rb 内部,路径是:
get '/:locale/feed', to: 'feed#index', as: 'feed'
我要粘贴下一段代码:
<%= link_to 'checkout', feed.paypal_url(products_url) %>
在模型 feed.rb 内部:
def paypal_url(return_url)
values = {
:business => 'my_paypal_mail@gmail.com',
:cmd => '_cart',
:upload => 1,
:return => return_url,
}
values.merge!({
"amount_1" => unit_price,
"item_name_1" => name,
"item_number_1" => id,
"quantity_1" => '1'
})
"https://www.sandbox.paypal.com/cgi-bin/webscr?" + values.to_query
end
但它打印出我:
undefined local variable or method `feed' for #<#<Class:0x007f5644b79520>:0x007f5644b89858>
开
<%= link_to 'checkout', feed.paypal_url(feeds_url) %>
有什么问题,我该如何解决这个错误?
更新
我只想将用于付款的按钮粘贴到我的网站,金额为 1 美元。我怎样才能做到?
【问题讨论】:
-
在您的帖子中添加 feeds_controller 和 index.html.erb 的完整内容。
标签: ruby-on-rails paypal