ActiveRecord :: StatementInvalid: PGError: ERROR: "instruction" relationships do not exist

Hi

I got this error when I test my rails application. I do not have a table named "instructions". But it shows an error, for example, the instructions โ€œERROR: relationโ€œ does not exist. โ€In general, I got the same error for 64 tests as 64 errors.

I am using rails 3.0, Ruby 1.9.2, Netbeans 6.8.

PS: I did not create an instruction manual for rails applications.

Error: test_should_get_index (HomeControllerTest): ActiveRecord :: StatementInvalid: PGError: ERROR: relationship "instructions" do not exist LINE 1: DELETE FROM "instructions" ^: DELETE FROM "instructions"

Please help me in this regard.

+4
source share
2 answers

You can run rake db:test:prepare , table instructions are not present in the test database.

+16
source

Check your lights. I used the error when using Rails forests to subclass.

The generator created files in my test / fixtures / directory that did not match the actual tables in my database (since the model used STI in another table).

When I ran the tests, Rails tried to create an instance of all my instruments, and an error similar to yours was generated when it was not possible to find a table corresponding to the name of the instrument.

Removing an unnecessary fixture file cleared my error and ran tests.

Hope this helps you or other people who come here to look for this error, like me .:]

+9
source

Source: https://habr.com/ru/post/1340158/


All Articles