I have technical question i have user model which have many questions so in my API controller i do:
render json: user, :include => {
:questions => {
:only => [:text]
},
}
Now i want to add to JSON response question count. How can i do that in best way. I know that i can create method inside model : count_question and after that do:
render json: user, :include => {
:questions => {
:only => [:text]
},
}, :methods => [
:count_question
]
and my response will be good. But is there better way to put that information to JSON. I want to avoid add method inside model. Is it possible to determine this count inside json renderer?
Greetings