I'm having trouble adjusting performance by returning json after a query to the database.
I've tried a lot of things, and I'm not getting any faster.
Can anyone give me strength with this?
This is the query in the controller
Methodnotmodel
Rabl
I'm having trouble adjusting performance by returning json after a query to the database.
I've tried a lot of things, and I'm not getting any faster.
Can anyone give me strength with this?
This is the query in the controller
Methodnotmodel
Rabl
As recommended by Carvalho paste your code into texts. It will be much simpler to help you, and you will get help easier and quicker if you do it the right way.
About your code. One of the things I'm fixing is that you're using SQL to scan the entire table and then do the processing of it. Try to minimize bank efforts in the array.
Come on, I would trade these methods for it
def students
works_students.where.not(student: nil)
end
def program_id
Qrcode.find_by(code: self.teacher_qrcode).try(:program_id)
end
I do not know about the rest. I'd have to take a closer look at your implementation.
I do not know how to create an association of has_one :qrcode
in model
teacher?
Having an association you could directly access the code by the controller like this:
work.teacher.qrcode.program_id