I have had to integrate a rails application with a legacy database. I
must say it worked out rather well, but now I need to create a separate
Rails app that also needs to use much of the same functionality that the
first app did. I started to separate out all the code I used in the
first app into a plugin that I can include in the new application (and
any additional in the future). With the exception of a separate
database connection in database.yml all the code for this are simple
ActiveRecord models. Is this the best direction for this?
The other issue I started to notice was that I should probably use some
sort of namespaces to prevent class conflicts. I started prefixing all
the models, currently 10 models in 10 files, with “Legacy::”, but that
broke all the associations between these models. Of which, there are a
lot. Is there a better way to handle this too?
As on last bonus, as all these models use a custom database connection
is it best to just add that connection to the database.yml file, or
(can) should I put that connection information somewhere else so it is
better associated with the plugin itself?
Thanks for any help in advance.