gpt4 book ai didi

ruby-on-rails - 错误 : No route matches [GET] "/cgi-bin/webscr"

转载 作者:太空宇宙 更新时间:2023-11-03 16:25:20 27 4
gpt4 key购买 nike

我正在尝试使用基本的 Paypal 为 Rails 众筹项目中的一项任务提供资金。当我点击特定任务的资金按钮时,我创建了一个新的资金表格,用于保存用户选择资金的金额,...等等。然而,在新的资金行动中,当用户点击资金时,我希望 Paypal 处理资金。然而,我目前收到错误:“没有路由匹配 [GET] “/cgi-bin/webscr”

这是我的资金控制者

class FundingsController < ApplicationController
def new
if params[:todo_item_id]
@todo_item = TodoItem.find(params[:todo_item_id])
@funding = Funding.new
#(todo_item: @todo_item, user_id: current_user.id)
raise ActiveRecord::RecordNotFound if @todo_item.nil?
end

end

def create
@funding = Funding.new(funding_params)
if @funding.save
redirect_to @funding.paypal_url(funding_path(@funding))
else
render :new
end
end


protect_from_forgery except: [:hook]
def hook
params.permit! # Permit all Paypal input params
status = params[:payment_status]
if status == "Completed"
@funding = Funding.find params[:invoice]
@funding.update_attributes notification_params: params, status: status, transaction_id: params[:txn_id], funded_at: Time.now
end
render nothing: true
end


private

def funding_params
params.require(:funding).permit(:todo_item_id, :user_id, :amount)
end
end

这是我的资金模型:

 class Funding < ActiveRecord::Base
has_one :card
belongs_to :todo_item
has_one :user

accepts_nested_attributes_for :card

def payment_method
if card.nil? then "paypal"; else "card"; end
end
serialize :notification_params, Hash
def paypal_url(return_path)
values = {
business: "mybusinesssandbox@gmail.com",
cmd: "_xclick",
upload: 1,
return: "#{Rails.application.secrets.app_host}#{return_path}",
invoice: id,
amount: self.amount,
item_name: self.todo_item.content,
item_number: self.todo_item.id,
quantity: '1',
notify_url: "#{Rails.application.secrets.app_host}/hook"
}
"#{Rails.application.secrets.paypal_host}/cgi-bin/webscr?" + values.to_query
end
end

我不确定为什么这个路由对我不起作用。另外,这是我的 app/views/fundings/new.html.erb::

  <h1><strong>Task:</strong> <%=@todo_item.content%><br>
<strong>Project:</strong> <%= @todo_item.todo_list.title%> </h1>
<%= form_for @funding, method: :post do |f| %>
<%= f.hidden_field :todo_item_id, value: @todo_item.id %>
<%= f.hidden_field :user_id, value: current_user.id %>
<%= f.label :amount, "Amount you wish to donate in $" %>
<%= f.number_field :amount %>
<%= submit_tag "Fund", class: 'btn btn_primary' %>
<%= link_to "Cancel", todo_list_path(@todo_item.todo_list_id, @todo_i), class: 'btn' %><br>
<%end%>

我哪里做错了?

最佳答案

"No route matches [GET] "/cgi-bin/webscr"

您正在向您的服务器而不是 Paypal 请求此资源。重新检查:

"#{Rails.application.secrets.paypal_host}/cgi-bin/webscr?" + values.to_query

Rails.application.secrets.paypal_host 可能是空白的!

关于ruby-on-rails - 错误 : No route matches [GET] "/cgi-bin/webscr",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34937332/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com