counter_culture
counter_culture copied to clipboard
Fix passing a proc to `column_names`
The documentation states
You can specify a scope instead of a where condition string for
column_names
. We recommend providing a Proc that returns a hash instead of directly providing a hash: If you were to directly provide a scope this would load your schema cache on startup which will break things likerake db:migrate
.
This doesn't work tho as the proc is immediately call
-ed in the counter_culture
method to check it's return value. To fix this I've moved the ArgumentError from the setup side to the runtime side.
options[:column_names]
could still be checked as a Hash or a Proc on startup, as it was before this commit :
https://github.com/magnusvk/counter_culture/commit/2a86dd82daefdc75744d08b42e50a5681239ebb2#diff-34fcb2d6df6a065b09e89f5e0980d73d3bd56f9e91c1bd71ded2ff36610df30aL48-R60
But yes, the proc should not be called on startup.
This fixes issue https://github.com/magnusvk/counter_culture/issues/347.
I've updated it to add back in the check for a hash or proc and raise an error if it's not one of those.
I'm running into this issue as well, any chance of getting this merged into the gem...? @magnusvk
Released in gem version 3.3.0. Sorry for the delay and thanks for the contribution.