I'm presently attempting to implement a log for that administration portion of my rails application. This can allow an admin to determine what actions a person has carried out so when. E.g 'User added a brand new address', 'User up-to-date their postcode from X to Y'.
As each action may potentially involve many models, not only the consumer, I've designed a log model that has fields for the other system models ids, a note along with a log code.
class CreateLogs < ActiveRecord::Migration def self.up create_table :logs do |t| t.integer :user_id t.integer :marker_id t.integer :administrator_id t.integer :group_id t.integer :assignment_id t.integer :submission_id t.integer :code t.text :message t.timestamps end end def self.down drop_table :logs end end
My problem is that for instance, a person could (let us say) add a project for their account, it will get drenched as
Log.create(:user_id => current_user.id, :assignment_id => the_assignment.id, :code => 342, :message => '')
(Somewhere the code 342 matches 'User produced a brand new address', hence no requirement for message)
Clearly inside a log view, I'm able to pull the appropriate user and address info in the log ids/particulars but when this user or address may be erased, everything information could be not available and thus searching back with the logs, the entry could be essentially useless.
There needs to be an easy method or something like that already available to assist log system occasions such as this and deal with potential deletions.
Alternatively I possibly could keep entire entry like a text but that would be really bad and fill the database unnecessarily?
Tell me if any one of that's unclear, just figured logging application actions/occasions needs to happen to be done before!