我正在为我的独立承包商创建一个表格,以更新其有关Stripe的法律信息。
目前,我的表单如下:
_legal_form.html.slim
- entity = current_user.stripe_entity.legal_entity
- is_individual = (entity['type'] == 'individual')
- is_business = !is_individual
- business_name = entity['business_name'] || ""
- business_tax_id = entity['business_tax_id'] || ""
= form_tag legal_entity_payment_path(current_user), id: 'legal-form' do
.form-group
label for="type" = t('payments.legal.type')
select id="type" class="form-control" onchange="showBusiness()"
- if is_individual
option value='business' = t('payments.legal.business')
option value='individual' selected="selected" = t('payments.legal.individual')
- else
option value='business' selected="selected"= t('payments.legal.business')
option value='individual' = t('payments.legal.individual')
.form-group id='business-fields' style="display:none"
label for="business_name" = t('payments.legal.business_name')
input id="business_name" type="text" class="form-control" value=business_name
label for="business_tax_id" = t('payments.legal.business_tax_id')
input id="business_tax_id" type="text" class="form-control" value=business_tax_id
.form-group class="form-inline"
.input-group
label for="dob_month" = t('payments.legal.dob.month')
input id="dob_month" type="number" class="form-control" value=entity.dob.month
.input-group
label for="dob_day" = t('payments.legal.dob.day')
input id="dob_day" type="number" class="form-control" value=entity.dob.day
.input-group
label for="dob_year" = t('payments.legal.dob.year')
input id="dob_year" type="number" class="form-control" value=entity.dob.year
.input-group
label for="ssn" = t('payments.legal.ssn')
input id="ssn" type="number" class="form-control" value=entity.ssn_last_4_provided
.form-group
label for="address" = t('payments.legal.address')
input id="address" type="text" class="form-control" value=entity.address.line1
.form-inline
.input-group
label for="city" = t('payments.legal.city')
input id="city" type="text" class="form-control" value=entity.address.city
.input-group
label for="state" = t('payments.legal.state')
select id="state" class="form-control" value=entity.address.state
option value="AL" = 'AL'
option value="AK" = 'AK'
option value="AZ" = 'AZ'
option value="AR" = 'AR'
option value="CA" = 'CA'
option value="CO" = 'CO'
option value="CT" = 'CT'
option value="DE" = 'DE'
option value="FL" = 'FL'
option value="GA" = 'GA'
option value="HI" = 'HI'
option value="ID" = 'ID'
option value="IL" = 'IL'
option value="IN" = 'IN'
option value="IA" = 'IA'
option value="KS" = 'KS'
option value="KY" = 'KY'
option value="LA" = 'LA'
option value="ME" = 'ME'
option value="MD" = 'MD'
option value="MA" = 'MA'
option value="MI" = 'MI'
option value="MN" = 'MN'
option value="MS" = 'MS'
option value="MO" = 'MO'
option value="MT" = 'MT'
option value="NE" = 'NE'
option value="NV" = 'NV'
option value="NH" = 'NH'
option value="NJ" = 'NJ'
option value="NM" = 'NM'
option value="NY" = 'NY'
option value="NC" = 'NC'
option value="ND" = 'ND'
option value="OH" = 'OH'
option value="OK" = 'OK'
option value="OR" = 'OR'
option value="PA" = 'PA'
option value="RI" = 'RI'
option value="SC" = 'SC'
option value="SD" = 'SD'
option value="TN" = 'TN'
option value="TX" = 'TX'
option value="UT" = 'UT'
option value="VT" = 'VT'
option value="VA" = 'VA'
option value="WA" = 'WA'
option value="WV" = 'WV'
option value="WI" = 'WI'
option value="WY" = 'WY'
.input-group
label for="postal_code" = t('payments.legal.postal_code')
input id="postal_code" type="text" class="form-control" value=entity.address.postal_code
button.btn.btn-primary = t('update')
javascript:
function showBusiness() {
var legal_type = document.getElementById("type");
var business_fields = document.getElementById("business-fields");
if (legal_type.value == 'business')
business_fields.style.display = 'block';
else
business_fields.style.display = 'none';
}
以及以下控制器方法:
stripe_controller.rb
def set_legal_entity
entity = current_user.stripe_entity
# begin
if current_user.is_driver?
entity.legal_entity.type = params[:type] || entity.legal_entity.type
entity.legal_entity.dob.month = params[:dob_month].to_i
entity.legal_entity.dob.day = params[:dob_day].to_i
entity.legal_entity.dob.year = params[:dob_year].to_i
entity.legal_entity.business_name = params[:business_name]
entity.legal_entity.business_tax_id = params[:business_tax_id]
entity.legal_entity.address.line1 = params[:address]
entity.legal_entity.address.city = params[:city]
entity.legal_entity.address.state = params[:state]
entity.legal_entity.address.postal_code = params[:postal_code]
entity.save
end
# rescue => e
# flash[:danger] = e.message
# Rails.logger.error "#{self.class}: #{e}"
# end
redirect_to dashboard_account_settings_path
end
当我提交表单时,没有任何信息保存为Stripe实体。
我想念什么吗?
答案 0 :(得分:1)
我认为您需要在帐户对象上调用project_associate_company
才能进行正确的API调用,而不是deleted_at
子哈希。因此,请尝试致电.save
。