I just realised that standard ActiveRecord actually hits the database when you do
person = Person.new(:name => "test")
I suspect ActiveRecord does this to check what fields are available for the model.
However, our legacy database is only occasionally available. That means that our test suite cannot run all the time. Are there any tricks to making this work without a database?
If it’s not possible, we thought of some alternatives:
- have a local copy of the database and work on that one
- use another ORM that solves this problem (DataMapper)
Any suggestions are welcome.
Working with a local copy is only possible if the data touched isn’t changed from anywhere else! Otherwise you will have a database disaster soon.
Your suspection is right too. ActiveRecord checks the Database for fields so it needs a connection. I don’t think there is a way to solve this when you want continue using ActiveRecord. I think you need to solve the underlying problem and run a database that is always available!