I have two models related with each other as below
class Weed < ApplicationRecord
has_many :user_transactions,:dependent => :destroy
end
This weed model has an attribute name county
and related model:
class UserTransaction < ApplicationRecord
belongs_to :weed
end
Now I want to fetch records from UserTransaction model on the basis of sort by county in weed model.
Please suggest me, How can I get correct result with in minimum complexity.
Thanks.
Aucun commentaire:
Enregistrer un commentaire