Skip to content

Instantly share code, notes, and snippets.

@Sephi-Chan
Created March 1, 2012 23:25
Show Gist options
  • Save Sephi-Chan/1953980 to your computer and use it in GitHub Desktop.
Save Sephi-Chan/1953980 to your computer and use it in GitHub Desktop.
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
@user.persistence_token = User.generate_persistence_token
@user.location = Location.find_available_location
if @user.save
cookies.permanent[:persistence_token] = @user.persistence_token
redirect_to root_path
else
render :new
end
end
def move
x = params[:x].to_i
y = params[:y].to_i
begin
current_user.move(x, y)
redirect_to game_path
rescue Location::NotAround
# Si le mec cherche à se déplacer trop loin.
rescue Location::NotOnBoard
# Si le mec sort du plateau.
rescue
# Toute autre erreur.
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment