Class: VotesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- VotesController
- Defined in:
- lib/controllers/votes_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /votes POST /votes.xml.
-
#destroy ⇒ Object
DELETE /votes/1 DELETE /votes/1.xml.
-
#edit ⇒ Object
GET /votes/1/edit.
-
#index ⇒ Object
GET /votes/ GET /votes.xml.
-
#new ⇒ Object
GET /votes/new GET /votes/new.xml.
-
#show ⇒ Object
GET /votes/1 GET /votes/1.xml.
-
#update ⇒ Object
PUT /votes/1 PUT /votes/1.xml.
Instance Method Details
#create ⇒ Object
POST /votes POST /votes.xml
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/controllers/votes_controller.rb', line 51 def create @vote = Vote.new(params[:vote]) @vote.user = current_user respond_to do |format| if @vote.save flash[:notice] = 'Vote was successfully saved.' format.html { redirect_to([@user, @vote]) } format.xml { render :xml => @vote, :status => :created, :location => @vote } else format.html { render :action => "new" } format.xml { render :xml => @vote.errors, :status => :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /votes/1 DELETE /votes/1.xml
86 87 88 89 90 91 92 93 94 |
# File 'lib/controllers/votes_controller.rb', line 86 def destroy @vote = Vote.find(params[:id]) @vote.destroy respond_to do |format| format.html { redirect_to(user_votes_url) } format.xml { head :ok } end end |
#edit ⇒ Object
GET /votes/1/edit
45 46 47 |
# File 'lib/controllers/votes_controller.rb', line 45 def edit @vote ||= Vote.find(params[:id]) end |
#index ⇒ Object
GET /votes/ GET /votes.xml
13 14 15 16 17 18 19 20 |
# File 'lib/controllers/votes_controller.rb', line 13 def index @votes = Vote.descending respond_to do |format| format.html # index.html.erb format.xml { render :xml => @votes } end end |
#new ⇒ Object
GET /votes/new GET /votes/new.xml
35 36 37 38 39 40 41 42 |
# File 'lib/controllers/votes_controller.rb', line 35 def new @vote = Vote.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @vote } end end |
#show ⇒ Object
GET /votes/1 GET /votes/1.xml
24 25 26 27 28 29 30 31 |
# File 'lib/controllers/votes_controller.rb', line 24 def show @vote = Vote.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @vote } end end |
#update ⇒ Object
PUT /votes/1 PUT /votes/1.xml
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/controllers/votes_controller.rb', line 69 def update @vote = Vote.find(params[:id]) respond_to do |format| if @vote.update_attributes(params[:vote]) flash[:notice] = 'Vote was successfully updated.' format.html { redirect_to([@user, @vote]) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @vote.errors, :status => :unprocessable_entity } end end end |