Hello,
When you say that the first model in the collection does not have the model attributes/methods, is it because you get a NoMethodError
exception when you attempt to invoke one of them?
It is normal for a model object not to have the attribute methods (e.g. when dumping the output of object.methods
) until you attempt to actually call them. When you attempt to call one of the missing methods in question, ActiveRecord
's method_missing
handler is triggered and, provided that the method name matches the name of one of the columns defined in the database, the method will be created dynamically and no exception will be risen. If that does not happen it is either because the object is of the wrong class (does not match the model you are expecting to be operating on), or because a plugin or gem is interfering by misbehaving in the method_missing
handling chain.
Can you dump into the logs (logger.info or logger.info, depending on your log level) what the attribute-less object instance's self.class.name equal to in? Can you also perform an audit of the gems (and corresponding versions) installed in production vs. locally?
Cheers,
V.