KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to interact with a .sqlite file by connecting to it with Active Record. I'm doing this: require 'active_record' # Connect to DB ActiveRecord::Base.establish_connection( :adapter => 'sqlite3', :database => 'database.sqlite') # Log the tables to make sure Active Record is connected to the DB correclty puts ActiveRecord::Base.connection.tables # Map from existing table records to a Active Record model class Patient < ActiveRecord::Base set_table_name "ZPATIENT" end The connection to the database works as printing out the database tables gives: ZPATIENT ZZCONFIG Z_PRIMARYKEY Z_METADATA But the attempt to map ZPATIENT table to Patient Active Record models fails with: ~/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `set_table_name' for Patient(Table doesn't exist):Class (NoMethodError) from script.rb:8:in `<class:Patient>' from script.rb:7:in `<main>' Not sure what I am doing wrong? Do I need to do some sort of migration for Active Record to understand how to map the table to models?
Tags (comma-separated)
Save Edits
Cancel