Closed ellneal closed 8 years ago
Again, another awesome feature! I've been wanting this myself for a while!
Previously I'd handle this by setting the :database_method
(example below) but your solution is much more elegant.
proxy_for :state_intervals, database_method: :state_intervals_proxy_database
def state_intervals_proxy_database
@state_intervals_proxy_database ||= self.class.prepare_database("#{slug}_state_intervals")
end
The current implementation only allows one proxy database per parent class.
In this example, both
invoices
andestimates
would be saved in the same database ("#{a_company.slug}"
). This PR adds two options to allow these classes to be saved in derived databases.Here, invoices will be saved in
"#{a_company.slug}_invoices"
and estimates will be saved in"#{a_company.slug}_documents"
.