So, I’m just trying to understand the console a bit better
I’m able to get some decent output through the console, but it’s a bit
short of what I want, which is to put the “calls” array together with
the
“logins” array and output the results as the SQL below does, something
like:
calls.comment calls.created_at logins.login
start work 2008-02-08 15:12:13 0123
start call 2008-02-08 15:12:13 0123
start break 2008-02-08 15:12:13 0123
How do you put it all together from the console? I can print out the
first two columns together, or print the third column, but cannot put
them together
thufir@arrakis ~/goodfellow-tool $
thufir@arrakis ~/goodfellow-tool $ script/console
Loading development environment.
calls=Call.find(:all, :conditions => {:login_id => 1})
=> [#<Call:0xb70747b8 @attributes={“id”=>“1”, “comment”=>“start work”,
“login_id”=>“1”, “created_at”=>“2008-02-08 15:12:13”}>,
#<Call:0xb707477c
@attributes={“id”=>“2”, “comment”=>“start call”, “login_id”=>“1”,
“created_at”=>“2008-02-08 15:12:13”}>, #<Call:0xb7074754 @attributes=
{“id”=>“3”, “comment”=>“start break”, “login_id”=>“1”,
“created_at”=>“2008-02-08 15:12:13”}>]calls.each {|call| puts call.comment + “\t” + call.created_at.to_s}
start work Fri Feb 08 15:12:13 -0800 2008
start call Fri Feb 08 15:12:13 -0800 2008
start break Fri Feb 08 15:12:13 -0800 2008
=> [#<Call:0xb70747b8 @attributes={“id”=>“1”, “comment”=>“start work”,
“login_id”=>“1”, “created_at”=>“2008-02-08 15:12:13”}>,
#<Call:0xb707477c
@attributes={“id”=>“2”, “comment”=>“start call”, “login_id”=>“1”,
“created_at”=>“2008-02-08 15:12:13”}>, #<Call:0xb7074754 @attributes=
{“id”=>“3”, “comment”=>“start break”, “login_id”=>“1”,
“created_at”=>“2008-02-08 15:12:13”}>]Login.find :all
=> [#<Login:0xb705c58c @attributes={“id”=>“1”, “employee_id”=>“1”,
“login”=>“0123”}>, #<Login:0xb705c550 @attributes={“id”=>“2”,
“employee_id”=>“1”, “login”=>“1234”}>, #<Login:0xb705c528 @attributes=
{“id”=>“3”, “employee_id”=>“2”, “login”=>“2345”}>]logins=Login.find(:all, :conditions => {:login => “0123”})
=> [#<Login:0xb7057190 @attributes={“id”=>“1”, “employee_id”=>“1”,
“login”=>“0123”}>]logins.each {|login| puts login.login}
0123
=> [#<Login:0xb7057190 @attributes={“id”=>“1”, “employee_id”=>“1”,
“login”=>“0123”}>]quit
thufir@arrakis ~/goodfellow-tool $
thufir@arrakis ~/goodfellow-tool $ sqlite3 db/development.sqlite3
SQLite version 3.4.1
Enter “.help” for instructions
sqlite> SELECT calls.comment,calls.created_at,logins.login FROM
calls,logins WHERE calls.login_id=1 AND logins.id=1;
start work|2008-02-08 15:12:13|0123
start call|2008-02-08 15:12:13|0123
start break|2008-02-08 15:12:13|0123
sqlite> .quit
thufir@arrakis ~/goodfellow-tool $