我正在尝试使用Stripe API创建信用卡表格。我不应该将db迁移为卡片形式,所以我只需要直接将信用卡信息发送到Stripe。
我使用var result = signInManager.PasswordSignInAsync(username, pass, true, true);
return result.Succeeded;
和一些JS文件。
这是开发此参考。
https://medium.com/@ThatGuyTinus/stripe-connect-rails-part-2-9751c0e553f9
发生错误:
的未定义方法`card_number'
观看次数(views / users / payment.html.erb):
gem 'gon'
Controllers(controllers / application_controller.erb):
<%= include_gon %>
<section class="registerCommunity">
<div class="wrapper">
<h2>Set up credit card</h2>
<%= form_for(@user, html: {class:'add-card'}) do |f| %>
<div class="block">
<%= f.hidden_field :stripe_temporary_token %>
<div class="formItem">
<%= f.label :card_number %>
<div class="formInput"><%= f.text_field :card_number, placeholder: "Enter card number", data: {stripe: 'number'} %></div>
</div>
・・・
视图(views / layouts / application.html.erb):
class ApplicationController < ActionController::Base
before_action :assign_env_variable
# Overwriting the sign_out redirect path method
def after_sign_out_path_for(resource)
new_user_session_path
end
def assign_env_variable
gon.stripe_key = ENV['PUBLISHABLE_KEY']
end
end
答案 0 :(得分:0)
我可以通过删除f.
来解决。
之前:
<div class="formItem">
<%= f.label :card_number %>
<div class="formInput"><%= f.text_field :card_number, placeholder: "Enter card number", data: {stripe: 'number'} %></div>
</div>
之后:
<div class="formItem">
<%= f.label :card_number %>
<div class="formInput"><%= text_field :card_number, placeholder: "Enter card number", data: {stripe: 'number'} %></div>
</div>