Class: Sechat::RepliesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Sechat::RepliesController
- Defined in:
- lib/sechat/controllers/replies_controller.rb
Instance Method Summary collapse
- #answer ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #load_question ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#answer ⇒ Object
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 |
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
20 21 22 |
# File 'lib/sechat/controllers/replies_controller.rb', line 20 def edit @reply = @question.replies.find(params[:id]) end |
#index ⇒ Object
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_question ⇒ Object
61 62 63 |
# File 'lib/sechat/controllers/replies_controller.rb', line 61 def load_question @question = Question.find(params[:question_id]) end |
#new ⇒ Object
15 16 17 18 |
# File 'lib/sechat/controllers/replies_controller.rb', line 15 def new @reply = @question.replies.build respond_with(@question, @reply) end |
#show ⇒ Object
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 |
#update ⇒ Object
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 |