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

标签 ruby-on-rails sqlite fixtures

编辑:这是与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/

相关文章:

ruby-on-rails - 如何在 rails (4.1.5) 中创建装置(对于设计用户)作为 yml.erb?

ruby-on-rails - Rails 应用程序可以处理多少并发上传

sqlite - 德尔福和SQLite : Get the records count per month for the last 12 months

ruby-on-rails - 如何创建一个在 Rails 5 中没有作用域的作用域?

java - 带有 Ormlite 和 JavaFX 的嵌入式 Sqlite 数据库 : error creating table

python - 如何在Python中使用并发来迁移数据库?

grails - Grails 中的 Fixtures 插件引用完整性异常

ruby-on-rails - 在 Rails 4 中使用具有间隙的 fixture 进行单元测试用户模型

ruby-on-rails - 带有扭矩箱和 nginx 的 EC2 错误网关

ruby-on-rails - 使用 capybara 和 Selenium 的 Chrome headless 下载 pdf