Class: Rostra::Base::AnswersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rostra/base/answers_controller.rb

Direct Known Subclasses

AnswersController

Instance Method Summary collapse

Methods inherited from ApplicationController

#can_participate_in_rostra?, #main_app_login_path, #main_app_signup_path, #rostra_user

Methods included from Config

setup

Instance Method Details

#createObject



15
16
17
18
19
20
21
# File 'app/controllers/rostra/base/answers_controller.rb', line 15

def create
  if @answer.save
    redirect_to question_path(@question)
  else
    render :new
  end
end

#editObject



23
24
# File 'app/controllers/rostra/base/answers_controller.rb', line 23

def edit
end

#updateObject



26
27
28
29
30
31
32
# File 'app/controllers/rostra/base/answers_controller.rb', line 26

def update
  if @answer.update_attributes(params[:answer])
    redirect_to question_path(@question, anchor: "rostra_answer_#{@answer.id}")
  else
    render :edit
  end
end

#voteObject



7
8
9
10
11
12
13
# File 'app/controllers/rostra/base/answers_controller.rb', line 7

def vote
  rostra_user.vote_on(@answer, params[:vote_direction])
  respond_to do |format|
    format.html { redirect_to question_path(@question, anchor: "rostra_answer_#{@answer.id}") }
    format.js
  end
end