Support multiple databases#521
Conversation
@michael-groble Did you get the error above and if so how did you work around the issue? |
|
I see failures in travis, @brand-it, but things run cleanly for me locally (on macos), e.g.: bundle exec rake
bundle exec appraisal rails50 rake
bundle exec appraisal rails51 rake
bundle exec appraisal rails52 rake
bundle exec appraisal rails60 rake(and the travis errors don't seem to match that abstract class error) |
|
Hi @michael-groble, I also have the same need that writing the audit logs to the second database. But I am having trouble with how to tell the CustomAudit to write the audit logs to the second database. Could you please tell me how to point audited to the second DB in the CustomAudit file? |
|
@LukeGuanY , that really depends on how you connect to multiple databases in the first place. I give an example above of rails 6. You can also set up a base that connects to a specific entry in you database configuration. For example, say your database config has a separate set of configuration for "warehouse" type tables, e.g. then you can have a base record (rails 5 this time) |
|
@michael-groble Thanks for the reply. I really appreciate your method. I am sharing my configuration here so that people can also learn it. I use the multiple database feature on Rail 6 Database.yml: Make an audit initializer at |
|
Probably related to this one #641 |
We would like to store the
auditstable in a separate database. With Rails 6 or ankane/multiverse, I can do that by setting up an abstract base record for all models I want to store in a secondary database:and would then want to set up the audit model to live there:
But since that
CustomAuditrecord does not inherit fromAudited::Audit, this won't really work.This pull request creates an
Audited::Auditableconcern which lets me store audits in the secondary database like so: