Class: Api::V1::QuestionsController

Inherits:
ApiController
  • Object
show all
Defined in:
app/controllers/answers/api/v1/questions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



15
16
17
18
19
# File 'app/controllers/answers/api/v1/questions_controller.rb', line 15

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

#destroyObject



27
28
29
30
31
# File 'app/controllers/answers/api/v1/questions_controller.rb', line 27

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

#indexObject



5
6
7
8
# File 'app/controllers/answers/api/v1/questions_controller.rb', line 5

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

#showObject



10
11
12
13
# File 'app/controllers/answers/api/v1/questions_controller.rb', line 10

def show
  question = Question.find(params[:id])
  render locals: {question: question}
end

#updateObject



21
22
23
24
25
# File 'app/controllers/answers/api/v1/questions_controller.rb', line 21

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