Class: AnswersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- AnswersController
- Defined in:
- app/controllers/answers_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /answers POST /answers.xml.
-
#destroy ⇒ Object
DELETE /answers/1 DELETE /answers/1.xml.
-
#edit ⇒ Object
GET /answers/1/edit.
-
#index ⇒ Object
GET /answers.xml.
-
#new ⇒ Object
GET /answers/new GET /answers/new.xml.
-
#show ⇒ Object
GET /answers/1 GET /answers/1.xml.
-
#update ⇒ Object
PUT /answers/1 PUT /answers/1.xml.
Instance Method Details
#create ⇒ Object
POST /answers POST /answers.xml
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/answers_controller.rb', line 43 def create @answer = Answer.new(params[:answer]) respond_to do |format| if @answer.save flash[:notice] = 'Answer was successfully created.' format.html { redirect_to(@answer) } format.xml { render :xml => @answer, :status => :created, :location => @answer } else format.html { render :action => "new" } format.xml { render :xml => @answer.errors, :status => :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /answers/1 DELETE /answers/1.xml
77 78 79 80 81 82 83 84 85 |
# File 'app/controllers/answers_controller.rb', line 77 def destroy @answer = Answer.find(params[:id]) @answer.destroy respond_to do |format| format.html { redirect_to(answers_url) } format.xml { head :ok } end end |
#edit ⇒ Object
GET /answers/1/edit
37 38 39 |
# File 'app/controllers/answers_controller.rb', line 37 def edit @answer = Answer.find(params[:id]) end |
#index ⇒ Object
GET /answers.xml
5 6 7 8 9 10 11 12 |
# File 'app/controllers/answers_controller.rb', line 5 def index @answers = Answer.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @answers } end end |
#new ⇒ Object
GET /answers/new GET /answers/new.xml
27 28 29 30 31 32 33 34 |
# File 'app/controllers/answers_controller.rb', line 27 def new @answer = Answer.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @answer } end end |
#show ⇒ Object
GET /answers/1 GET /answers/1.xml
16 17 18 19 20 21 22 23 |
# File 'app/controllers/answers_controller.rb', line 16 def show @answer = Answer.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @answer } end end |
#update ⇒ Object
PUT /answers/1 PUT /answers/1.xml
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/answers_controller.rb', line 60 def update @answer = Answer.find(params[:id]) respond_to do |format| if @answer.update_attributes(params[:answer]) flash[:notice] = 'Answer was successfully updated.' format.html { redirect_to(@answer) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @answer.errors, :status => :unprocessable_entity } end end end |