Sha256: e185c494602c45eaec4255ce5691b9aee9f76eab14c21f21bc9192b5e8abbbc8

Contents?: true

Size: 898 Bytes

Versions: 2

Compression:

Stored size: 898 Bytes

Contents

module Answers
  class Api::V1::QuestionsController < Api::V1::ApiController
    respond_to :json

    def index
      questions = Question.all
      render locals: {questions: questions}
    end

    def show
      question = Question.find(params[:id])
      render locals: {question: question}
    end
  
    def create
      question = Question.new(question_params)
      question.save
      render 'questions/show', locals: {question: question}
    end

    def update
      question = Question.find(params[:id])
      question.update(question_params)
      render 'questions/show', locals: {question: question}
    end

    def destroy
      question = Question.find(params[:id])
      question.destroy
      render 'questions/show', locals: {question: question}
    end

    private

      def question_params
        params.require(:question).permit(:text, :in_language)
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
answers-core-0.0.0.2 app/controllers/answers/api/v1/questions_controller.rb
answers-core-0.0.0 app/controllers/answers/api/v1/questions_controller.rb