gpt4 book ai didi

ruby-on-rails - 加载Rails固定装置时获取“没有命名为列”

转载 作者:行者123 更新时间:2023-12-03 18:19:35 29 4
gpt4 key购买 nike

编辑:这是与Rails 2.3.5

出于某种原因,当我尝试在项目中将信用卡与Band关联时,出现以下错误

SQLite3::SQLException: table credit_cards has no column named band: INSERT INTO "credit_cards" ("created_at", "vault_token", "billing_zipcode", "billing_first_name", "updated_at", "band", "billing_state", "billing_city", "id", "billing_email_address", "billing_country", "billing_address", "billing_phone_number", "billing_last_name") VALUES ('2010-10-08 03:26:07', 'vaulttokenvalue', 12345, 'Test', '2010-10-08 03:26:07', 'beekin', 'TX', 'AnyCity', 714867248, 'none@none.com', 'US', '1234 Any Street', '5555555555', 'User')




SQLite3::SQLException: table bands has no column named credit_card: INSERT INTO "bands" ("name", "created_at", "next_payment_date", "updated_at", "credit_card", "account_type_id", "id", "hometown_city", "account_status", "subdomain", "hometown_state", "website", "account_type_name") VALUES ('Beekin', '2010-10-08 03:29:16', '2010-10-07', '2010-10-08 03:29:16', 'card_one', 715507355, 862144657, 'Nashville', 'ACTIVE', 'beekin', 'TN', 'http://www.beekin.com', 'MONTHLY')


我的迁移看起来像

class CreateCreditCards < ActiveRecord::Migration
def self.up
create_table :credit_cards do |t|
t.references :band
t.string :billing_first_name
t.string :billing_last_name
t.string :billing_address
t.string :billing_city
t.string :billing_state
t.string :billing_zipcode
t.string :billing_country
t.string :billing_email_address
t.string :billing_phone_number
t.string :vault_token

t.timestamps
end

add_column :bands, :credit_card_id, :integer
end
end


我的bands.yml装置看起来像:

beekin:
name: Beekin
website: "http://www.beekin.com"
hometown_city: Nashville
hometown_state: TN
subdomain: beekin
account_type: monthly
account_type_name: "MONTHLY"
account_status: "ACTIVE"
credit_card: card_one
next_payment_date: <%= Date.today %>


我的credit_cards.yml固定装置如下所示:

card_one:
band: beekin
billing_first_name: Test
billing_last_name: User
billing_address: "1234 Any Street"
billing_city: AnyCity
billing_state: TX
billing_zipcode: 12345
billing_country: US
billing_email_address: "none@none.com"
billing_phone_number: "5555555555"
vault_token: vaulttokenvalue


有人可以指出我在做什么错。我已经将其与其他灯具进行了比较,看起来它应该可以工作,但事实并非如此。

具有has_one:credit_card(在band模型中)和belongs_to:band(在credit_card模型中)。我现在真的迷路了。

最佳答案

card_one:
band_id: 1 //or any other Band id
billing_first_name: Test
billing_last_name: User
billing_address: "1234 Any Street"
billing_city: AnyCity
billing_state: TX
billing_zipcode: 12345
billing_country: US
billing_email_address: "none@none.com"
billing_phone_number: "5555555555"
vault_token: vaulttokenvalue




beekin:
name: Beekin
website: "http://www.beekin.com"
hometown_city: Nashville
hometown_state: TN
subdomain: beekin
account_type: monthly
account_type_name: "MONTHLY"
account_status: "ACTIVE"
credit_card_id: 1 // or any other Card id
next_payment_date: <%= Date.today %>

关于ruby-on-rails - 加载Rails固定装置时获取“没有命名为列”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3887531/

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