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