jeudi 27 juillet 2017

What should I name my fixture file for a model with the name Mls

I have an activerecord model Mls in the directory app/models/mls.rb.

I have the corresponding fixture in test/fixtures/mls.rb.

When I run rails test I receive the error:

ActiveRecord::NotNullViolation: PG::NotNullViolation: ERROR:  null value in column "created_at" violates not-null constraint

The error is a little misleading, it is actually caused by the model not being found (http://ift.tt/2uGBwB0).

Naming the fixture mls.yml causes rails to look for the model file named ml.rb.

When I run Mls.name.underscore.pluralize I get "Mls" as the response. When I run "Mls.name.pluralize.singularize" I get "Ml" as the response.

It seems my only choice is rename my model but possibly there is another solution?

Aucun commentaire:

Enregistrer un commentaire