This is more a ruby question than rails, really, but here goes:
How does the "row" ?variable? come into play? That is, how is it used?
Somehow, "login" needs to be defined so that the effect is similar to
what's in db/migrate/001_calls.rb :
Call.create :login => "0123"
However, the data must be read from data.csv (which I can do), then, somehow, Call.create needs to happen. No?
What I currently have:
thufir@arrakis ~/goodfellow-tool/db $ thufir@arrakis ~/goodfellow-tool/db $ ruby import.rb /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/ connection_adapters/sqlite_adapter.rb:360:in `table_structure': ActiveRecord::StatementInvalid (ActiveRecord::StatementInvalid) from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/core_ext/object/misc.rb:23:in `returning' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/connection_adapters/sqlite_adapter.rb:359:in `table_structure' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/connection_adapters/sqlite_adapter.rb:210:in `columns' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/base.rb:763:in `columns' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/base.rb:2063:in `attributes_from_column_definition_without_lock' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/locking/optimistic.rb:45:in `attributes_from_column_definition' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/base.rb:1505:in `initialize_without_callbacks' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/callbacks.rb:225:in `initialize' from import.rb:12:in `new' from import.rb:12 from /usr/lib/ruby/gems/1.8/gems/fastercsv-1.2.3/lib/ faster_csv.rb:1458:in `each' from /usr/lib/ruby/gems/1.8/gems/fastercsv-1.2.3/lib/ faster_csv.rb:1003:in `foreach' from /usr/lib/ruby/gems/1.8/gems/fastercsv-1.2.3/lib/ faster_csv.rb:1175:in `open' from /usr/lib/ruby/gems/1.8/gems/fastercsv-1.2.3/lib/ faster_csv.rb:1002:in `foreach' from import.rb:8 thufir@arrakis ~/goodfellow-tool/db $ thufir@arrakis ~/goodfellow-tool/db $ cat ruby import.rb cat: ruby: No such file or directory require 'rubygems' require 'fastercsv' require '/home/thufir/goodfellow-tool/config/environment.rb'
infile = "data.csv"
FCSV.foreach(infile) do |row|
login = row[0]
Call.new( :login => login ) end thufir@arrakis ~/goodfellow-tool/db $ thufir@arrakis ~/goodfellow-tool/db $ cat data.csv "one" "two" "three" thufir@arrakis ~/goodfellow-tool/db $
thanks,
Thufir