Logger's sync and flush returns NoMethod error

R

RichardOnRails

Hi,

Below is my code, which works fine in Ruby 1.8.6 (with Rails 2.3.5),
except that sync and flush both return NoMethod. Have thos methods
been eliminated?

Thanks in Advance,
Richard

equire 'rubygems'
require 'active_record'

class Account < ActiveRecord::Base
set_table_name "accounts"
has_many :comments
end

class Comment < ActiveRecord::Base
set_table_name "comments"
belongs_to :account
end

ActiveRecord::Base.establish_connection(
:adapter => 'mysql',
:host => 'localhost',
:database => 'test',
:username => 'root',
:password => "rlmrlm")

mylog = Logger.new('mylog.txt')
# mylog.sync = true # NoMethod
error
ActiveRecord::Base.logger = mylog
temp = Account.find(1)
mylog.info("Found a record with username: #{temp.username}" )
mylog.info('About to show comments')
temp.comments.each do |rec|
puts "#{temp.username} said #{rec.subject}"
end
#mylog.flush # NoMethod
error
 
B

Brian Candler

RichardOnRails said:
Below is my code, which works fine in Ruby 1.8.6 (with Rails 2.3.5),
except that sync and flush both return NoMethod. Have thos methods
been eliminated?

sync= and flush are instance methods on IO objects. I don't think Logger
has them. Do you have anything which suggests that it does/did?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top