'parse-stack' (Rails) : NoMethodError, but method exists

I’m creating new Message objects, which have a messageBody attribute, using Rails and the parse-stack gem. The following is from a debugging session (byebug in Rails) on my localhost. Note that message (a new object) and foo (pre-existing) are both, to outward appearance, the same class, but foo has messageBody and messageBody= methods defined, whereas message doesn’t:

(byebug)  foo = Message.find("Dfz49lOcyF")
I, [2021-12-10T09:43:07.870952 #32042]  INFO -- request: GET https://dev-api.redacted.io/parse/classes/Message/Dfz49lOcyF
D, [2021-12-10T09:43:07.871857 #32042] DEBUG -- request: User-Agent: "Parse-Stack v1.8.1"
I, [2021-12-10T09:43:08.218936 #32042]  INFO -- response: Status 200
D, [2021-12-10T09:43:08.220452 #32042] DEBUG -- response: server: "nginx/1.18.0 (Ubuntu)"
date: "Fri, 10 Dec 2021 16:43:08 GMT"
content-type: "application/json; charset=utf-8"
content-length: "333"
connection: "close"
x-powered-by: "Express"
access-control-allow-origin: "*"
access-control-allow-methods: "GET,PUT,POST,DELETE,OPTIONS"
access-control-allow-headers: "X-Parse-Master-Key, X-Parse-REST-API-Key, X-Parse-Javascript-Key, X-Parse-Application-Id, X-Parse-Client-Version, X-Parse-Session-Token, X-Requested-With, X-Parse-Revocable-Session, X-Parse-Request-Id, Content-Type, Pragma, Cache-Control"
access-control-expose-headers: "X-Parse-Job-Status-Id, X-Parse-Push-Status-Id"
etag: "W/\"14d-A77L4oJp4Y4I1vbK35gyBPpt/s8\""
#<Message:0x007ff79e05c790 @id="Dfz49lOcyF", @message_body="test manually", @conversation=#<Conversation:0x007ff79df53b78 @id="oc0VYzUlgz", @acl=ACL({"*"=>{"read"=>true, "write"=>true}}), @previously_changed={}, @mutations_before_last_save=nil, @attributes_changed_by_setter={}, @mutations_from_database=nil, @fetch_lock=false>, @created_at=Tue, 30 Nov 2021 22:36:30 +0000, @updated_at=Fri, 10 Dec 2021 16:41:29 +0000, @acl=ACL({"*"=>{"read"=>true, "write"=>true}}), @previously_changed={}, @mutations_before_last_save=nil, @attributes_changed_by_setter={}, @mutations_from_database=nil, @sender=#<Parse::User:0x007ff79d250cc8 @id="IgQ5hj0T7d", @acl=ACL({"*"=>{"read"=>true, "write"=>true}}), @previously_changed={}, @mutations_before_last_save=nil, @attributes_changed_by_setter={}, @mutations_from_database=nil, @fetch_lock=false>>
(byebug) foo.messageBody = "test to change"
"test to change"
(byebug) foo.class
Message
(byebug) message.class
Message
(byebug) message.messageBody
*** NoMethodError Exception: undefined method `messageBody' for #<Message:0x007ff79fefa3f0>

nil
(byebug) foo.messageBody
"test to change"
(byebug) foo.save
I, [2021-12-10T09:44:41.695713 #32042]  INFO -- request: PUT https://dev-api.redacted.io/parse/classes/Message/Dfz49lOcyF
D, [2021-12-10T09:44:41.695909 #32042] DEBUG -- request: User-Agent: "Parse-Stack v1.8.1"
I, [2021-12-10T09:44:42.026058 #32042]  INFO -- response: Status 200
D, [2021-12-10T09:44:42.026352 #32042] DEBUG -- response: server: "nginx/1.18.0 (Ubuntu)"
date: "Fri, 10 Dec 2021 16:44:41 GMT"
content-type: "application/json; charset=utf-8"
content-length: "40"
connection: "close"
x-powered-by: "Express"
access-control-allow-origin: "*"
access-control-allow-methods: "GET,PUT,POST,DELETE,OPTIONS"
access-control-allow-headers: "X-Parse-Master-Key, X-Parse-REST-API-Key, X-Parse-Javascript-Key, X-Parse-Application-Id, X-Parse-Client-Version, X-Parse-Session-Token, X-Requested-With, X-Parse-Revocable-Session, X-Parse-Request-Id, Content-Type, Pragma, Cache-Control"
access-control-expose-headers: "X-Parse-Job-Status-Id, X-Parse-Push-Status-Id"
etag: "W/\"28-w0TAFoqh3GOVfSeVRvCZYEVRknA\""
true
(byebug)

How can I coerce message into having the messageBody methods that objects of the class Message are supposed to have? What confusion of concepts have I made that is being masked by the fact that both of them appear to be of the same class?

Can you share how you are defining the message var? Maybe you should try to set the messageBody?

      message = Message.new(
        messageBody: message.nil? ? message_body : message,
        conversation: Pointer.do("Conversation", conversation&.objectId),
        sender: Pointer.do("_User", @user&.objectId)
      )

where message_body is set above this block, as a string value.

The odd-looking line messageBody: message.nil? ? message_body : message comes from a previous dev, and I’ve tried writing it without the conditional, like messageBody: message_body. Neither way works.

Just in order to test, If you use something like messageBody: "some message", does it work?

Assigning a string directly works, but assigning it to a variable like message_body and using messageBody: message_body fails, for some reason. It doesn’t if not trying to call it asynchronously.

you may have something wrong with your message_body var. If you want to share the whole code that reproduced the problem, it might be easier to help.