Answer the question
In order to leave comments, you need to log in
Why can't I access a private method from the same object?
class SayController < ApplicationController
def hello
@message = { message: 'Hello', payload: self.payload }
render json: @message
end
private
def payload
{ size: 12, file_type: 'png', name: 'photo!' }
end
end
Answer the question
In order to leave comments, you need to log in
replace self.payload with payload.
An object is not allowed to call private methods.
Only a class can do this internally.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question