A bit cleaner way of selecting map pairs, bunch of other cleanup crap generally characterized as removing generated Rails code
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
class MapsController < ApplicationController
|
||||
# GET /maps
|
||||
# GET /maps.xml
|
||||
def index
|
||||
@maps = Map.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xml { render :xml => @maps }
|
||||
format.html
|
||||
format.xml { render :xml => @maps }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,66 +25,4 @@ class MapsController < ApplicationController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# GET /maps/new
|
||||
# GET /maps/new.xml
|
||||
def new
|
||||
@map = Map.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @map }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /maps/1/edit
|
||||
def edit
|
||||
@map = Map.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /maps
|
||||
# POST /maps.xml
|
||||
def create
|
||||
@map = Map.new(params[:map])
|
||||
|
||||
respond_to do |format|
|
||||
if @map.save
|
||||
flash[:notice] = 'Map was successfully created.'
|
||||
format.html { redirect_to(@map) }
|
||||
format.xml { render :xml => @map, :status => :created, :location => @map }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @map.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /maps/1
|
||||
# PUT /maps/1.xml
|
||||
def update
|
||||
@map = Map.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @map.update_attributes(params[:map])
|
||||
flash[:notice] = 'Map was successfully updated.'
|
||||
format.html { redirect_to(@map) }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.xml { render :xml => @map.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /maps/1
|
||||
# DELETE /maps/1.xml
|
||||
def destroy
|
||||
@map = Map.find(params[:id])
|
||||
@map.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(maps_url) }
|
||||
format.xml { head :ok }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -19,7 +19,6 @@ class MashesController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xml { render :xml => @mash }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,15 +27,15 @@ class MashesController < ApplicationController
|
||||
mash_params[:requester] = request.remote_ip
|
||||
logger.info("Got mash params: #{mash_params.inspect}")
|
||||
@mash = Mash.new(mash_params)
|
||||
@winner = Map.find(@mash.winner)
|
||||
@winner.points += 1
|
||||
|
||||
respond_to do |format|
|
||||
if @mash.save
|
||||
if @mash.save && @winner.save
|
||||
flash[:notice] = 'Mash was successfully created.'
|
||||
format.html { redirect_to(:action => 'new') }
|
||||
format.xml { render :xml => @mash, :status => :created, :location => @mash }
|
||||
else
|
||||
format.html { render :action => 'new' }
|
||||
format.xml { render :xml => @mash.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user