Displaying 1 result from an estimated 1 matches for "fix_history".
2006 Apr 06
7
LoginSystem : make @session available to models
...of the altered model
:ref_id # the id of the altered model
(In models/history.rb)
class History < ActiveRecord::Base
def ref=(object)
write_attribute(''ref_table'', object.class.table_name)
write_attribute(''ref_id'', object.id)
end
before_create :fix_history
before_update :fix_history
def fix_history
write_attribute(''user_id'', session[:user].id) if user_id.nil?
write_attribute(''date'', Time.now) if date.nil?
end
end
--
Posted via http://www.ruby-forum.com/.