I have a serializer with a has_many
association and I want to order the dependent model. For some reason I get an undefined method key?'
error:
class API::ClientSerializer < ActiveModel::Serializer
has_many :check_ins, -> { order(:week) }
end
How else do I order the check_ins by week?
class API::ClientSerializer < ActiveModel::Serializer
has_many :check_ins do
object.check_ins.order(:week)
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With