Production Routing Issues? Customized code in lib? Reload young man, reload!
We recently experienced some challenging issues when pushing fully tested code to production. Wholesale functionality ceased to work.
What to do? We had prior experience with an old mangy dog hangin' on to long. After killing that mongrel, all was well.
This time, however, the solution was not easy found.
After a bit of mucking around, I remembered that the model in question is not handle properly with the inflections built in with rails. This was cured with a bit of code in our project_init.rb in lib:
Inflector.inflections do |inflect|
# inflect.irregular('tax', 'taxes')
inflect.plural /^(tax)$/i, '\1\2es'
inflect.singular /^(tax)es/i, '\1'
end
This worked well in development, but the routes were failing in prod. Solution Reload!!
Inflector.inflections do |inflect|
# inflect.irregular('tax', 'taxes')
inflect.plural /^(tax)$/i, '\1\2es'
inflect.singular /^(tax)es/i, '\1'
end
ActionController::Routing::Routes.reload
Reloading the routing after the new inflection rules are loaded is the key.
ActionController::Routing::Routes.reload