Open jonlhouse opened 12 years ago
You can specify create_view order in config/application.rb
# Configure VIEWs creation orders
ActiveRecord::SchemaDumper.view_creation_order = ['view_e_periodical_citations','view_periodical_citations']
This seems to be a general problem. I'm building an example app, following the docs and I'm having the same problem, when trying to do
rake db:test:prepare
It seems that views are dumped alphabetically by default. The real solution would be to follow the migration order. Any ideas how to achieve this automatically?
I'm not 100% sure about this as a bug in general or on my end but here's the situation:
It looks like the schema.rb "create_view" entries are populated alphabetically. This is a problem when a child model references a parent model who's view is not yet defined.
Here's my example: I have data model for literature citations in which
class EPeriodicalCitation < PeridoicalCitation
Since 'view_e_periodical_citations' is < 'view_periodical_citations' it gets output first and causes an ERROR when
rake db:test:prepare
is run.The simple fix for me was to reorder the schema.rb file so that base views are referenced before child views. I don't know if a general fix based on class hierarchy is easy or difficult but I thought I'd pass along the message.