ruby on rails - Model.to_a throws undefined method to_a -
I wanted to solve this Rail 4 dislikes warning:
Relation # is all disliked if you If you want to load any relation anxious, you can call # load (eg post where (published: truth).) If you want to get a record from a relationship, you can call #to_a (like post. Where (published: true) .to_a).
So when I change Model.all to Model.to_a, this undefined method throws to_a.
When I try Model.Scoped.to_a, it works for example where and scope series.
Should I go through a scoped or a better solution?
If you really want an array, then you should use it:
< Pre Model.all.to_a
Since the Rail 4 all
method return relationship, relation # all
has been excluded .
Comments
Post a Comment