Why am I getting error: Object of class Craft\ElementCriteriaModel could not be converted to int We just created an entry and hit save.  When we go to the front end of site we get a popup error that reads: 


  Object of class Craft\ElementCriteriaModel could not be converted to
  int


What does this mean and how do I troubleshoot it
The ElementCriteriaModel is an object that prepares your queries. For example when you do craft.entries you'll receive an ElementCriteriaModel where you can insert ids, sections, relations and many other attributes until you finally fetch your entries with find(), first() or ids(). 

When you have a relation field attached to the entry the values of these fields are objects of type ElementCriteriaModel too, so you have a ready to use query that can be executed. 

This class has an iterator interface, that means the method find() is executed when you loop through it, that being said for image in entry.images does actually for image in entry.images.find(). Thus many people think entry.images contains an array of elements rather than one single element. 

So - for future reference - when you ever receive an error like


  Object of class Craft\ElementCriteriaModel could not be converted to XXX


It's likely you treated your ElementCriteriaModel as an array or element or string or whatever the error explains. 

In your special case it was just a syntax error: change gridImages.length to gridImages|length