vendredi 6 septembre 2019

Use Rails 4 Syntax For Associations in Rails 3.2

Is there any way I can support the Rails 4 syntax for defining associations in Rails 3.2?

I currently have the following Rails 4 syntax:

has_many :clients, -> { where("client_type = 'temp'").order("name DESC") }

I want my Rails 3.2 app to support that syntax. In essence, it's as if I had written the following in Rails 3.2:

has_many :clients, conditions: "client_type = 'temp'", order: "name DESC"

Is there a library/gem that enables this support? Any ideas on how to accomplish this?

Aucun commentaire:

Enregistrer un commentaire