Class: Mg::ChoicesController
- Defined in:
- lib/mountain-goat/controllers/mg/choices_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /mg/tests/:test_id/choices POST /mg/tests/:test_id/choices.xml.
-
#destroy ⇒ Object
DELETE /mg/choices/1 DELETE /mg/choices/1.xml.
-
#edit ⇒ Object
GET /mg/choices/1/edit.
-
#index ⇒ Object
GET /mg/choices GET /mg/choices.xml.
-
#new ⇒ Object
GET /mg/tests/:test_id/choices/new GET /mg/tests/:test_id/choices/new.xml.
-
#show ⇒ Object
GET /mg/choices/1 GET /mg/coihces/1.xml.
-
#update ⇒ Object
PUT /mg/choices/1 PUT /mg/choices/1.xml.
Instance Method Details
#create ⇒ Object
POST /mg/tests/:test_id/choices POST /mg/tests/:test_id/choices.xml
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/mountain-goat/controllers/mg/choices_controller.rb', line 45 def create @test = Mg::Test.find( params[:choice][:mg_test_id] ) @choice = Mg::Choice.new(params[:choice]) if @choice.save flash[:notice] = 'Choice was successfully created.' redirect_to mg_test_url :id => @choice.mg_test.id else render :action => "new" end end |
#destroy ⇒ Object
DELETE /mg/choices/1 DELETE /mg/choices/1.xml
72 73 74 75 76 77 78 79 80 |
# File 'lib/mountain-goat/controllers/mg/choices_controller.rb', line 72 def destroy @choice = Mg::Choice.find(params[:id]) @choice.destroy respond_to do |format| format.html { redirect_to mg_choices_url } format.xml { head :ok } end end |
#edit ⇒ Object
GET /mg/choices/1/edit
39 40 41 |
# File 'lib/mountain-goat/controllers/mg/choices_controller.rb', line 39 def edit @choice = Mg::Choice.find(params[:id]) end |
#index ⇒ Object
GET /mg/choices GET /mg/choices.xml
6 7 8 9 10 11 12 13 |
# File 'lib/mountain-goat/controllers/mg/choices_controller.rb', line 6 def index @choices = Mg::Choice.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @choices } end end |
#new ⇒ Object
GET /mg/tests/:test_id/choices/new GET /mg/tests/:test_id/choices/new.xml
28 29 30 31 32 33 34 35 36 |
# File 'lib/mountain-goat/controllers/mg/choices_controller.rb', line 28 def new @test = Mg::Test.find( params[:test_id] ) @choice = Mg::Choice.new( :mg_test_id => @test.id ) respond_to do |format| format.html # new.html.erb format.xml { render :xml => @choice } end end |
#show ⇒ Object
GET /mg/choices/1 GET /mg/coihces/1.xml
17 18 19 20 21 22 23 24 |
# File 'lib/mountain-goat/controllers/mg/choices_controller.rb', line 17 def show @choice = Mg::Choice.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @choice } end end |
#update ⇒ Object
PUT /mg/choices/1 PUT /mg/choices/1.xml
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/mountain-goat/controllers/mg/choices_controller.rb', line 59 def update @choice = Mg::Choice.find(params[:id]) if @choice.update_attributes(params[:choice]) flash[:notice] = 'Choice was successfully updated.' redirect_to mg_test_url :id => @choice.mg_test.id else render :action => "edit" end end |