Hi, I’m building a database and I need to save all the changes users do.
This means that every time something goes to the method update, create
or destroy I have to save some information in another table. That’s
fine, the problem is that I need to store all the new information in one
field, and the old information in another.
I tried to do so doing the following:
The problem is that neither params[:empresa].to_s nor :tupla_antiguo => @tupla
are save as readable information… I think I might need to do some
kind of method to get everything in one big string… while I do thata,
Anybody have a smarter solution?
The problem is that neither params[:empresa].to_s nor :tupla_antiguo => @tupla
are save as readable information… I think I might need to do some
kind of method to get everything in one big string… while I do thata,
Anybody have a smarter solution?
You can turn an object into a big string (in Rails) by using the to_yaml
method. In my app this looks like this:
The problem is that neither params[:empresa].to_s nor :tupla_antiguo => @tupla
are save as readable information… I think I might need to do some
kind of method to get everything in one big string… while I do thata,
Anybody have a smarter solution?
I think you have to ‘flatten’ a hash to a string.
check out ‘acts_as_audited’ which probably does what you want to do or
will show you the code they use which might give you inspiration.
Great I did it.
Maybe you know more about act_as_audited and can help me with this.
I have a table “people” that is related wuith the table “area” through
the table “peoplearea”, meaning that each person may have many areas.
The “peoplearea” and the “people” models are being audited, and it
works. The problem is that if I’m editing a person info, and I add or
delete a new area, the “audits” table show this changes as destroying or
creating the table “peoplearea” and I need to be saved as a change made
over the person. Is this possible with this plugin?
Thanks for your help.
Hi, I’m building a database and I need to save all the changes users do.
This means that every time something goes to the method update, create
or destroy I have to save some information in another table.
You can also use ActiveRecord::Observer for this. See docs