我不明白为什么会出现错误:
could not find table libraryusers10s
在下面的代码中,我定义了两个表library_users10
和library_books10
,并将它们与类相关联。
以下代码工作正常:
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => "library8")
ActiveRecord::Schema.define do
create_table :library_users10 do |table|
table.column :user_id, :integer
table.column :name, :string
table.column :age, :string
table.column :books_borrowed, :integer
end
create_table :library_books10 do |table|
table.column :books_id, :integer
table.column :borrower_id, :integer
table.column :title, :string
table.column :borrowed, :string
table.column :due_back, :string
end
end
class LibraryUsers10 < ActiveRecord::Base
has_many :library_books9s
end
class LibraryBooks10 < ActiveRecord::Base
belongs_to :library_users10s
end
但是当我尝试填充表时,通过将以下代码添加到脚本中,我得到了错误could not find table libraryusers10s
libraryusers10 = LibraryUsers10.create(:user_id => 1, :name => 'Tom', :age => 10, :books_borrowed => 3 )
libraryusers10.library_books10.create(:borrower_id => 1, :title => 'Who let the dogs out?', :borrowed => '13_November_2013', :due_back => '21_November_2013' )
有人对这里出了什么问题有任何建议吗?
谢谢你的帮助。