我在尝试将braintree gem 合并到我的rails 3 应用程序时遇到错误。真正奇怪的是,我能够成功地将它安装在我系统上的一个应用程序中,然后当我尝试在另一个应用程序上运行它时出现以下错误:
undefined local variable or method `confirm_payment_url' for #<#<Class:0x103a2bf08>:0x103a2a298>
这是我正在使用的默认代码:
<h1>Payment: $<%= h @amount %></h1>
<% if @result -%>
<div style="color: red;"><%= h @result.errors.size %> error(s)</div>
<% end -%>
<%= form_for :transaction,
:params => @result && @result.params[:transaction],
:errors => @result && @result.errors.for(:transaction),
:builder => ApplicationHelper::BraintreeFormBuilder,
:url => Braintree::TransparentRedirect.url,
:html => {:autocomplete => "off"} do |f| -%>
<%= field_set_tag "Customer" do -%>
<%= f.fields_for :customer do |c| -%>
<div><%= c.label :first_name, "First Name" %></div>
<div><%= c.text_field :first_name %></div>
<div><%= c.label :last_name, "Last Name" %></div>
<div><%= c.text_field :last_name %></div>
<div><%= c.label :email, "Email" %></div>
<div><%= c.text_field :email %></div>
<% end -%>
<% end -%>
<%= field_set_tag "Credit Card" do -%>
<%= f.fields_for :credit_card do |c| -%>
<div><%= c.label :number, "Number" %></div>
<div><%= c.text_field :number %></div>
<div><%= c.label :expiration_date, "Expiration Date (MM/YY)" %></div>
<div><%= c.text_field :expiration_date %></div>
<div><%= c.label :cvv, "CVV" %></div>
<div><%= c.text_field :cvv %></div>
<% end -%>
<% end -%>
<%= hidden_field_tag :tr_data, Braintree::TransparentRedirect.transaction_data(
:redirect_url => confirm_payment_url,
:transaction => {:type => "sale", :amount => @amount}
) %>
<%= f.submit "Submit" %>
<% end -%>
这是付款控制器
def confirm
@result = Braintree::TransparentRedirect.confirm(request.query_string)
if @result.success?
render :action => "confirm"
else
@amount = calculate_amount
render :action => "new"
end
end
什么类型的更改可能会产生这种结果,其中一个 rails 应用程序会识别此方法,而另一个不会?真的在这个问题上摸不着头脑。谢谢你的帮助。