Class: Sechat::RepliesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/sechat/controllers/replies_controller.rb

Instance Method Summary collapse

Instance Method Details

#answerObject



47
48
49
50
51
52
53
# File 'lib/sechat/controllers/replies_controller.rb', line 47

def answer
  @reply = @question.replies.find(params[:id])
  @reply.toggle!(:answer)
  
  respond_with(@question, @reply,
    :location => question_path(@question, :anchor => "A#{@reply.to_param}"))
end

#createObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/sechat/controllers/replies_controller.rb', line 24

def create
  @reply = @question.replies.build(params[:reply])
  @reply.save
  
  respond_with(@question, @reply) do |format|
    format.html do
      if @reply.persisted?
        redirect_to question_path(@question, :anchor => "A#{@reply.to_param}")
      else
        render 'new'
      end
    end
  end
end

#destroyObject



55
56
57
58
59
# File 'lib/sechat/controllers/replies_controller.rb', line 55

def destroy
  @reply = @question.replies.find(params[:id])
  @reply.destroy
  respond_with(@question, @reply)
end

#editObject



20
21
22
# File 'lib/sechat/controllers/replies_controller.rb', line 20

def edit
  @reply = @question.replies.find(params[:id])
end

#indexObject



5
6
7
8
# File 'lib/sechat/controllers/replies_controller.rb', line 5

def index
  @replies = @question.replies.all
  respond_with(@question, @replies)
end

#load_questionObject



61
62
63
# File 'lib/sechat/controllers/replies_controller.rb', line 61

def load_question
  @question = Question.find(params[:question_id])
end

#newObject



15
16
17
18
# File 'lib/sechat/controllers/replies_controller.rb', line 15

def new
  @reply = @question.replies.build
  respond_with(@question, @reply)
end

#showObject



10
11
12
13
# File 'lib/sechat/controllers/replies_controller.rb', line 10

def show
  @reply = @question.replies.find(params[:id])
  respond_with(@question, @reply)
end

#updateObject



39
40
41
42
43
44
45
# File 'lib/sechat/controllers/replies_controller.rb', line 39

def update
  @reply = @question.replies.find(params[:id])
  @reply.update_attributes(params[:reply])
  
  respond_with(@question, @reply,
    :location => question_path(@question, :anchor => "A#{@reply.to_param}"))
end