Template render error


Hi All,
I tried to get all data from database by querying from model, simply by using StatusTruk.all().
Actually i have model Truck, truck has many Status which are in Status Truck.
I use that data to populate a dropdown of truck status when viewing the detail of a truck, and it’s working for some truck, but it’s also not working for some truck, and shows error like shown in the image below.
This is the script :
{% yield status = StatusTruk.all() %}
This is the error :

I need your help guys, thanks for your attentions.



Hey @nagaitan! :wave:

You should never have async content in your view.
You must get all of your StatusTruk inside your controller and then pass the value to your view.


hai thanks @romain.lanz
i know it should be called in controller,
but actually it’s working for another trucks, it only shows that error for some trucks.

I don’t really understand what is query that executed behind code Model.All, do you have idea about that?


According to the query shown by the error message you are trying to fetch a specific model using a code like StatusTruk.find().


@romain.lanz yeah, right. I just don’t have an idea why that error comes since sometimes it’s working.


I recommend you first to move this code into your controller and then try to find where you are calling Model.find() without a parameter.