Class: ActiveRecordSurveyApi::QuestionsController
Instance Method Summary
collapse
#all_questions, #find_survey, #json_params, #new_question, #question_by_id, #question_params
Instance Method Details
#create ⇒ Object
27
28
29
30
31
32
33
|
# File 'app/controllers/active_record_survey_api/questions_controller.rb', line 27
def create
@question = new_question(question_params)
@survey.build_question(@question)
@survey.save
render json: @question, serializer: QuestionSerializer
end
|
#index ⇒ Object
15
16
17
18
19
|
# File 'app/controllers/active_record_survey_api/questions_controller.rb', line 15
def index
@questions = all_questions
render json: @questions, each_serializer: QuestionSerializer, meta: { total: @questions.length }
end
|
#show ⇒ Object
21
22
23
24
25
|
# File 'app/controllers/active_record_survey_api/questions_controller.rb', line 21
def show
@question = question_by_id(params[:id])
render json: @question, serializer: QuestionSerializer
end
|