I am new to ruby and writing a small script that requires writing messages to a database log.
I am using ruby 1.9.3 with active_record but without rails. All select stat
I checked the API and the methods you're using are current. I think you may need attr_accessor
class ActLog < ActiveRecord::Base
attr_accessor :id, :level, :message, :module, :date
self.table_name = "ActLog"
self.primary_key = "ID"
end
def log(level, message)
attr = { :level => level.upcase!,
:message => message,
:module => 'script',
:date => Time.new.strftime("%Y-%m-%d %H:%M:%S") }
ActLog.new(attr).save!
end
I think your class should be as follows:
class ActLog < ActiveRecord::Base
self.primary_key = 'ID'
self.table_name = 'ActLog'
end
Out of curiosity, why the non-standard names?