vendredi 29 janvier 2021

Custom association in Rails 3.2 to preload query

I am using Rails 3.2.13 and Ruby 2.0.0.

I want to preload an association with conditions but when I write association (order_last_email ) it gives an error.

wrong number of arguments (1 for 0)

Here is a sample of the code.

class Company < AbstractModel
 has_many :emails

 # extra association
 has_one :order_last_email, -> { recent.last }, class_name: "Email"  
end

Aucun commentaire:

Enregistrer un commentaire