|
|
@ -1,22 +1,11 @@
|
|
|
|
class MashesController < ApplicationController
|
|
|
|
class MashesController < ApplicationController
|
|
|
|
|
|
|
|
def redirect_to_new
|
|
|
|
def index
|
|
|
|
flash[:notice] = 'Sneaky pete.'
|
|
|
|
@mashes = Mash.all
|
|
|
|
redirect_to(:action => 'new')
|
|
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
|
|
|
format.html
|
|
|
|
|
|
|
|
format.xml { render :xml => @mashes }
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def show
|
|
|
|
alias_method :index, :redirect_to_new
|
|
|
|
@mash = Mash.find(params[:id])
|
|
|
|
alias_method :show, :redirect_to_new
|
|
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
|
|
|
format.html
|
|
|
|
|
|
|
|
format.xml { render :xml => @mash }
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def new
|
|
|
|
def new
|
|
|
|
@map_a, @map_b = Map.rand(2)
|
|
|
|
@map_a, @map_b = Map.rand(2)
|
|
|
@ -25,7 +14,7 @@ class MashesController < ApplicationController
|
|
|
|
:requester => request.remote_ip,
|
|
|
|
:requester => request.remote_ip,
|
|
|
|
:map_a => @map_a.id,
|
|
|
|
:map_a => @map_a.id,
|
|
|
|
:map_b => @map_b.id,
|
|
|
|
:map_b => @map_b.id,
|
|
|
|
:winner => 'a'
|
|
|
|
:winner => @map_a.id
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
@ -34,47 +23,20 @@ class MashesController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def edit
|
|
|
|
|
|
|
|
@mash = Mash.find(params[:id])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create
|
|
|
|
def create
|
|
|
|
@mash = Mash.new(params[:mash])
|
|
|
|
mash_params = params[:mash]
|
|
|
|
|
|
|
|
mash_params[:requester] = request.remote_ip
|
|
|
|
|
|
|
|
@mash = Mash.new(mash_params)
|
|
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
if @mash.save
|
|
|
|
if @mash.save
|
|
|
|
flash[:notice] = 'Mash was successfully created.'
|
|
|
|
flash[:notice] = 'Mash was successfully created.'
|
|
|
|
format.html { redirect_to(@mash) }
|
|
|
|
format.html { redirect_to(:action => 'new') }
|
|
|
|
format.xml { render :xml => @mash, :status => :created, :location => @mash }
|
|
|
|
format.xml { render :xml => @mash, :status => :created, :location => @mash }
|
|
|
|
else
|
|
|
|
else
|
|
|
|
format.html { render :action => "new" }
|
|
|
|
format.html { render :action => 'new' }
|
|
|
|
format.xml { render :xml => @mash.errors, :status => :unprocessable_entity }
|
|
|
|
format.xml { render :xml => @mash.errors, :status => :unprocessable_entity }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
|
|
|
|
@mash = Mash.find(params[:id])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
|
|
|
if @mash.update_attributes(params[:mash])
|
|
|
|
|
|
|
|
flash[:notice] = 'Mash was successfully updated.'
|
|
|
|
|
|
|
|
format.html { redirect_to(@mash) }
|
|
|
|
|
|
|
|
format.xml { head :ok }
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
format.html { render :action => "edit" }
|
|
|
|
|
|
|
|
format.xml { render :xml => @mash.errors, :status => :unprocessable_entity }
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
|
|
|
|
@mash = Mash.find(params[:id])
|
|
|
|
|
|
|
|
@mash.destroy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
|
|
|
format.html { redirect_to(mashes_url) }
|
|
|
|
|
|
|
|
format.xml { head :ok }
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|