I am getting array after processing.
gem 'active_model_serializers'
Now i want to use serializer to send data in json format.
But when i called the serializer, it'll not getting object because of Array.
Controller -
def index
question = user.questions.available
answer = user.where(:answer => params[:ans])
render :json => {:qust => question, :each_serializer => QuestionSerializer,
:ans => answer, :each_serializer => AnswerSerializer}
end
question_serializer.rb
class QuestionSerializer < ActiveModel::Serializer
attributes :id, :question, :type
end
answer_serializer.rb
class AnswerSerializer < ActiveModel::Serializer
attributes :id, :answer, :date
def date
object.date = "..."
end
end