i am a novice in ruby. i am trying my hands on sqlite3.
i have 2 tables books and users, users can have manty books and books belong to user which is established in program.
however i get following errors when i run mu file
Program Files (x86)/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-active_record/connection_adapters/sqlite3_adapter.rb:511:in table_structure': Could not find table 'libusers' (ActiveRecord::StatementInvalid)
from C:/Program Files (x86)/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/sqlite3_adapter.rb:385:in
columns'
from C:/Program Files (x86)/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/schema_cache.rb:43:in columns'
from C:/Program Files (x86)/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.2.4/lib/active_record/attributes.rb:93:in
columns'
from C:/Program Files (x86)/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.2.4/lib/active_record/attributes.rb:98:in columns_hash'
from C:/Program Files (x86)/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.2.4/lib/active_record/inheritance.rb:205:in
subclass_from_attributes?'
from C:/Program Files (x86)/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.2.4/lib/active_record/inheritance.rb:54:in new'
from C:/Program Files (x86)/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-4.2.4/lib/active_record/persistence.rb:33:in
create'
i read about these error and ran rake db:migrate it says no rake file found i am stuck and need help
require 'active_record'
require 'sqlite3'
`enter code here`ActiveRecord::Base.establish_connection(:adapter => "sqlite3",:database => "memory")
class Clean < ActiveRecord::Migration
def self.up
#ActiveRecord::Schema.define do
create_table :users do |table|
table.column :name, :string
table.column :age, :integer
table.column :books_borrowed,:integer
end
create_table :books do |table|
table.column :borrower, :string
table.column :title, :string
table.column :borrow_date, :string
table.column :due_date, :string
end
end
def self.down
drop_table :users
drop_table :books
end
end
class Libuser < ActiveRecord::Base
has_many :books
end
class Books< ActiveRecord::Base
belongs_to :user
end
#Clean.down
Clean.up
user= Libuser.create(:name=>"Megna", :age=>25, :books_borrowed=>2 )
user.books.create(:title=>"immortals of meluha", :borrow_date=>"12 jan 2015", :due_date=>"22 jan 2015")
user.books.create(:title=>"secret of nagas", :borrow_date=>"24 jan 2015", :due_date=>"2 Feb 2015")
user= Libuser.create(:name=>"sandhya", :age=>27, :books_borrowed=>3 )
user.books.create(:title=>"ugly duckling ", :borrow_date=>"12 feb 2015", :due_date=>"22 feb 2015")
user.books.create(:title=>"Little red riding Hood", :borrow_date=>"24 march 2015", :due_date=>"2 april 2015")
user.books.create(:title=>"Little red riding Hood", :borrow_date=>"12 april 2015", :due_date=>"22 april 2015
")
thanks in advance